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

ServerScriptService.Script:29: attempt to get length of global 'Players' (a nil value) ?

Asked by 6 years ago

local mode = true game.Players.PlayerAdded:connect(function(plr) if mode == true then plr.TeamColor = game.Teams["Humans"].TeamColor else plr.TeamColor = game.Teams["Creepers"].TeamColor end end) while true do wait(1) if game.Players.NumPlayers > 1 then print "Starting game" for i = 5, 1, -1 do print(i .. " seconds until night") wait(1) end print "Night Begins" local Plrs = game.Players:GetPlayers() local creeper = Plrs[math.random(1,#Players)] print('Selected player was: ' ..creeper.Name) else print "There needs to be 2 players to start" end end

script breaking at chosing random players?

1
"#Players". Players isn't defined anywhere. Try replacing that with #Plrs. call23re2 87 — 6y
0
oh thx THEROBLOXAIN2 15 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You never stated what Players was.

Line 28. You need a table containing a list of players.

Ad

Answer this question