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

Why will my script for a part being clicked granting you the option to buy a gamepass not work?

My current script:

local CLICK_BLOCK = script.Parent
local ITEM_ID = 8827494 -- My gamepass

local Click = Instance.new("ClickDetector", CLICK_BLOCK)

Click.MouseClick:Connect(function(player)
	game:GetService("MarketplaceService"):PromptGamepassPurchace(player,ITEM_ID)
end)

5 comments

0

You spelled PromptGamePassPurchase wrong. Should be PromptGamePassPurchase.

0

yup

0

Oh ok! I will try this now!

0

Well, It does not work. Like most of my things.

0

My bad. I forgot to say that this should be in a LocalScript, which should be in your Part. Then change "player" on line 7 to "game.Players.LocalPlayer". You don't need a click detector either. Instead, use MouseButton1Click. I will show you the complete script down below.

1 answer

✓ Accepted answer

Local Script

local CLICK_BLOCK = script.Parent.ClickDetector
local ITEM_ID = 8827494 -- My gamepass

CLICK_BLOCK.MouseClick:Connect(function()
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,ITEM_ID)
end)

Hope this helps!

5 comments

0

Do I still keep a Click Detector in the part?

0

Ok.

0

I was wondering because it did not work either.

0

Im flipping done with this. Have some points.

0

Oh, I'm sorry that I was not able to help. Thank you for accepting anyways, and good luck with your game!

This discussion is preserved as it was. New answers, comments, and votes are closed.