I think I'm struggling at the conceptual level with regard to what happens when you pass the "player" argument in the first script. I thought the first and second scripts should work because, ultimately, "game.players.LocalPlayer" is being passed into the PromptGamePassPurchase function.

This is the version of the script that works:

id = 0000

script.Parent.Click.MouseClick:Connect(function(player)
	game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
end)

This does not work:

id = 0000
player = game.Players.LocalPlayer

script.Parent.Click.MouseClick:Connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
end)

4 comments

0

Did you put the second in a LocalScript?

1

LocalScripts cannot operate within workspace (it is a global environment), otherwise, the LocalPlayer is invalid in a regular Script due to it being souly orientated on the Server—the Server doesn't have a Player Object.

0

^

0

^