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

Why isn't this script working? It's supposed to add bool?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    game.Players:WaitForChild(player)
    print("I have waited now.")
    game.Players.player:WaitForChild("PlayerGui")
    print("That too.")
    local A = Instance.new("IntValue")
    A.Parent = game.Players.player.PlayerGui
    A.Name = "PlayerStatus"
    A.Value = 5
end)

Not working at all. When I join it basically says that PlayerGui is not a valid member of Player. What's that supposed to mean? Please help. It's broken. It's supposed to add an IntValue.

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Remember, player is an object, not a string. You also have no need to do game.Players.player, you can just use player.

game.Players.PlayerAdded:connect(function(plr)
    repeat wait() until plr.Character --Waits until the character is loaded.
    local A = Instance.new("IntValue")
    A.Parent = player.PlayerGui
    A.Name = "PlayerStatus"
    A.Value = 5
end)
0
Make sure you're testing it on a server, NOT IN PLAY SOLO! PlayerAdded events DO NOT WORK in play solo. Perci1 4988 — 10y
0
Not working! It doesn't create the INTVALUE in PlayerGui :( Overpride 0 — 10y
0
Oh you have to test it in online mode, my bad Overpride 0 — 10y
0
It's in a server script, right? Perci1 4988 — 10y
View all comments (2 more)
0
Nevermind. Perci1 4988 — 10y
0
Omg it's official! I placed the script itself directly into PlayerGui which was WHY it didn't execute. It needed to be in workspace. *FACEPALM * FACEPALM * *TRIPLE FACEPALM* otherwise the script would've WORKED!!! Overpride 0 — 10y
Ad

Answer this question