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

Can anyone tell me what I've done wrong?

local Click = script.Parent.Parent.Parent.Parent.Click
local ID = 170753509
script.Parent.MouseButton1Down:connect(function(Player)
	Click:Play()
	Game:GetService("MarketplaceService"):PromptPurchase(Player, ID)
end)

This is the error note,"Unable to cast value to Object". By the way, it's on line 5. The script is contained inside of a SurfaceGui ImageButton.

1 answer

✓ Accepted answer

The problem is you can't get the player in a SurfaceGui with MouseButton1Down. Put the SurfaceGui in StarterGui, then Adornee it to a certain part you'd like and use a localscript in the SurfaceGui so you can make a LocalPlayer variable.

You can use the Command Bar to Adornee it, I hope this helped (:

1 comment

0

Thanks!

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