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)
player.CharacterAdded:Connect(function(char)
local playerRole = Instance.new("StringValue")
playerRole.Name = "PlayerRole"
playerRole.Parent = player
while wait(20) do local plrs = game.Players
for _,players in pairs(game.Players:GetChildren()) do
if #game.Players:GetChildren() == 1 then
players.PlayerGui:WaitForChild("RoleGui").WaitingText.Visible = true
else
players.PlayerGui:WaitForChild("RoleGui").WaitingText.Visible = false
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
if player ~= randomPlayer then
player.PlayerGui:WaitForChild("RoleGui").Frame.RoleText.TextColor3 = Color3.fromRGB(0,255,0)
player:WaitForChild("PlayerRole").Value = "Survivor"
player.PlayerGui:WaitForChild("RoleGui").Frame.RoleText.Text = player:WaitForChild("PlayerRole").Value
player.PlayerGui:WaitForChild("RoleGui").Frame:TweenPosition(UDim2.new(0.339,0,0.24,0),"Out","Elastic",0.7)
table.insert(survivors,player)
wait(5)
player.PlayerGui:WaitForChild("RoleGui").Frame:TweenPosition(UDim2.new(0.339,0,1.5,0),"In","Elastic",0.7)
end
end
end
end
end
end)
end)

1 comment
Thank you very much, that was one of the problems with it, the other was something else but this 100% helped too!