Why do I keep getting a nil value if OBVIOUSLY there is a value being shown in the player?
So, I'm trying to make a RoleGui and there were many errors with it, but luckily I was able to fix them except one where I keep getting a "nil value"?
Here's the code: local survivors = {}
game.Players.PlayerAdded:Connect(function(player)
1 | player.CharacterAdded:Connect( function (char) |
3 | local playerRole = Instance.new( "StringValue" ) |
4 | playerRole.Name = "PlayerRole" |
5 | playerRole.Parent = player |
while wait(20) do
local plrs = game.Players
for _,players in pairs(game.Players:GetChildren()) do
1 | if #game.Players:GetChildren() = = 1 then |
3 | players.PlayerGui:WaitForChild( "RoleGui" ).WaitingText.Visible = true |
6 | players.PlayerGui:WaitForChild( "RoleGui" ).WaitingText.Visible = false |
7 | local randomPlayer = plrs:GetPlayers(math.random( 1 ,#plrs:GetPlayers())) |
randomPlayer:WaitForChild("PlayerRole").Value = "Murder"
randomPlayer.PlayerGui:WaitForChild("RoleGui").Frame.RoleText.TextColor3 = Color3.fromRGB(255,0,0)
randomPlayer.PlayerGui:WaitForChild("RoleGui").Frame.RoleText = randomPlayer:WaitForChild("PlayerRole").Value
local clone = game.ServerStorage["Murder Knife"]:Clone()
clone.Parent = randomPlayer.Backpack
for _,player in pairs(plrs:GetPlayers()) do
01 | if player ~ = randomPlayer then |
03 | player.PlayerGui:WaitForChild( "RoleGui" ).Frame.RoleText.TextColor 3 = Color 3. fromRGB( 0 , 255 , 0 ) |
05 | player:WaitForChild( "PlayerRole" ).Value = "Survivor" |
07 | player.PlayerGui:WaitForChild( "RoleGui" ).Frame.RoleText.Text = player:WaitForChild( "PlayerRole" ).Value |
09 | player.PlayerGui:WaitForChild( "RoleGui" ).Frame:TweenPosition(UDim 2. new( 0.339 , 0 , 0.24 , 0 ), "Out" , "Elastic" , 0.7 ) |
11 | table.insert(survivors,player) |
15 | player.PlayerGui:WaitForChild( "RoleGui" ).Frame:TweenPosition(UDim 2. new( 0.339 , 0 , 1.5 , 0 ), "In" , "Elastic" , 0.7 ) |
end
end
end)