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

How do I get this SurfaceGUI Button to work?

Im trying to make a surfaceGUI shop.. and this isnt working... can someone help?

local assetId = 223132588 --Insert any object Id
 
local player = script.Parent.Parent.Parent.Parent
while not player:IsA("Player") do player = player.Parent end 
 
script.Parent.TextButton.MouseButton1Down:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(player, assetId)
end)

2 comments

0

You can't grab the player like that. The highest order in the hierarchy you'd get would be 'game'. Is this SurfaceGui inside either 'StarterPack' or 'StarterGui'? If not, I'd recommend you put it there and set its 'Adornee' to the actual part in Workspace. Then you could use 'LocalPlayer' with a localscript.

0

If this is a localscript, just use game.Players.LocalPlayer to get a reference to the player object.

1 answer

usually changing this to a script might help... or u might have to define the function on line 6

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