How could i fix 'attempt to index nil with 'waitforchild'?
Asked by
4 years ago Edited 4 years ago
What i am trying to do is, when the player selects the red team, it changes the value of intValue teamPicked to 1, and stringValue of TEAM to "blue", the error im getting is attempt to index nil with 'WaitForChild', ive also tried not using waitforchild and some other ways but it still did not work. I apologize if there is not enough information, but this is all i have so far:
01 | local player = game.Players.LocalPlayer |
02 | local plr = script.Parent.Parent.Parent.Parent.Name |
03 | local playerInfo = game.Players.LocalPlayer:WaitForChild( "playerInfo" ) |
04 | local teamPicked = player.playerInfo:WaitForChild( "teamPicked" ) |
06 | script.Parent.MouseButton 1 Click:connect( function () |
07 | game.Players [ plr ] .Team = game.Teams.Blue |
08 | game.Players [ plr ] .TeamColor = BrickColor.new( "Lapis" ) |
09 | script.Parent.Parent.Enabled = false |
11 | game.ReplicatedStorage.TEAM = "blue" |
the problem is in row 3