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

Why wont this split up all players in a server?

local bool = false
local players = game.Players:GetPlayers() 
local team1 = game.Teams.Team1 
local team2 = game.Teams.Team2 


while true do
wait(1)
if game.Players.NumPlayers ==1 then 
wait(1)
print("Starting game")	
for _,v in next, players do
    bool = not bool
    v.TeamColor = ((bool1 and team1.TeamColor) or team2.TeamColor)
		end
	end
end

I have no clue why this script wont get all the player and assign them to the team to split up the server? Any help?

1 comment

0

Make sure to check the output for any errors.

1 answer

bool1 should be bool
Also == should be >

This was a sloppy mistake. Make sure you're naming your variables correctly and managing your conditions properly. Please in the future proofread your scripts when you're copy-pasting all willy-nilly.

local bool = false
local team1 = game.Teams.Team1 
local team2 = game.Teams.Team2 


while true do
wait(1)
if game.Players.NumPlayers > 1 then -- More than 1 player?
wait(1)
print("Starting game")  
local players = game.Players:GetPlayers() -- Update your players here
for _,v in next, players do
    bool = not bool
    v.TeamColor = bool and team1.TeamColor or team2.TeamColor -- bool
        end
    end
end

1 comment

0

Hmm it still wont team the player ? ;/

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