So I am trying to make an object that can be clicked, and when clicked it will prompt the player to buy a gamepass. I have the script inside a ClickDetecter which is inside the object. Here is what I tried but it didn't work.
local player = game.Players.LocalPlayer
local id = 573965111
script.Parent.Clicker.ClickDetector.MouseClick:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(player, id)
end)
If anyone could tell me what I am doing wrong or how to fix it I would be very grateful.
Thanks in advanced!

11 comments
If you're trying to make it a surface gui you need to put the GUI in StarterGui and set the Adornee property to the part with which you want the gui to be on.
I don't understand what you mean, if you're talking about the button that can be displayed on your screen that's not what I mean, I mean to be able to click an object.
You're gonna have to use a surfacegui since the Clicker object is in the workspace and clickdetectors can't tell you who clicked it. If you don't want to do that then I guess you could use local parts, but I doubt you're ready for that.
Okay thanks!
I tried that V
That's is wrong Meltdown81. ClickDetectors will provide you the player who clicked the part, regardless now if FilteringEnabled is turned on or not. The Event will provide the player as an argument to the function to be utilized at the developer's discretion.
Is this a server script or local script? Is it in Workspace or somewhere in player? https://scriptinghelpers.org/blog/common-mistakes
It's in a workspace.
Is it a ServerScript or LocalScript?
Ahh Server script, yeah, yeah, serverscript.
Don't Worry Guys! I Figured it out!