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

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

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

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)

6 comments

0

Make sure you're testing it on a server, NOT IN PLAY SOLO! PlayerAdded events DO NOT WORK in play solo.

0

Not working! It doesn't create the INTVALUE in PlayerGui :(

0

Oh you have to test it in online mode, my bad

0

It's in a server script, right?

0

Nevermind.

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!!!

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