Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PlayerGui is not a valid member of Player?

Asked by 10 years ago

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

Log in to vote
2
Answered by 10 years ago
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.

0
Ok thanks! CardboardRocks 215 — 10y
Ad

Answer this question