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

PlayerGui is not a valid member of Player?

That's the error that pops up when I put this script. Any ideas as to why it's not working? It's in the StarterPack talking to the StarterGui.

Player = game.Players.GetChildren -- "Player" is the games Players children.
local productId = 19191511
playerr = game.Players.LocalPlayer

playerr.PlayerGui.Shop.A.MouseButton1Click:connect(function()
	Game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

1 answer

✓ Accepted answer
Player = game.Players:GetPlayers() -- "Player" is the games Players children.
local productId = 19191511
playerr = game.Players.LocalPlayer

playerr:WaitForChild("PlayerGui").Shop.A.MouseButton1Click:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(playerr, productId)
end)

Presumably, the code was running before the PlayerGui loaded.

1 comment

0

Ok thanks!

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