When I advertise my game, I want to make money. So, I want to make a brick that when you click it, it prompts a gamepass. How do I do that?
✓ ANSWER ACCEPTED
How to make a brick that prompts a gamepass when you click it?
2 answers
✓ Accepted answer
function onClicked()
local player = game.Players.LocalPlayer
game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id) -- id is the id of the gamepass
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Should work, but put the script in the part, and have a ClickDetector in the part aswell. Hope it helps!
script.Parent.ClickDetector.MouseClick:Connect(function(player)
game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 00000000) -- id of your gamepass
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
this doesn't work because a server script cannot access LocalPlayer