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

Inside a TextButton: MarketplaceService:PromptPurchase()?

MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil

Hello, I am trying to make it to where I can click on my GUI and click the textbutton and the game will prompt me to buy a GamePass. But I receive the error above. How do I go about this? The gui is in the Starter pack and it is in a script not a LocalScript.

local id = 0

function onClick()
script.Parent.MouseButton1Click:connect(function(player)
	game:GetService("MarketplaceService"):PromptPurchase(player, id)
end )
end

script.Parent.MouseButton1Click:connect(onClick)

1 answer

✓ Accepted answer

Mousebutton1Click does not give a player parameter. I think you were confused with ClickDetectors.

This should be in a LocalScript because Gui is client-side.

Once in a LocalScript you can use game.Players.LocalPlayer

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