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
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.
If this is a localscript, just use game.Players.LocalPlayer to get a reference to the player object.