Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a brick that prompts a gamepass when you click it?

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?

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!

1 comment

0

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

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.