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

Team divide doesn't work, all players are put on one team when countdown begins?

Asked by 8 years ago
Edited 8 years ago
maps = game.Lighting.Maps:GetChildren()
h = Instance.new("Hint", game.Workspace)
player = game.Players.LocalPlayer

while true do   
    if game.Players.NumPlayers > 1 then
        h.Text = "Deciding What Map To Play"
        wait(3)
        ranGame = math.random(1, #maps)
        mapChosen = maps[ranGame]
        h.Text = "Map Chosen: " .. mapChosen.Name
        wait(3)                 
        mapChosenClone = mapChosen:clone()
        mapChosenClone.Parent = game.Workspace
-- Above clones maps and runs with map chosen in hint

            local players = game.Players:GetPlayers()       
                for i = 1, #players do
                    local player = players[i] 
    if 1 % 2 == 0 then
                 player.TeamColor = BrickColor.new("Black") 
                else player.TeamColor = BrickColor.new("White")
    end
                end
-- Above is the broken team divider

                    for i,v in pairs(game.Players:GetPlayers()) do
if v.Character ~= nil then
if v.Character.Humanoid ~=0 then
v.Character.Humanoid.Health = 0
end
end
                    end
-- Above kills Player

        for i = 220, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)


            wait(1)

        end
-- Above is countdown
        h.Text = "Game ended"

-- Game ending hint
    for i,v in pairs(game.Players:GetPlayers()) do
if v.Character ~= nil then
if v.Character.Humanoid ~=0 then
v.Character.Humanoid.Health = 0
end
end
    end
-- Kills player to respawn

        local players = game.Players:GetPlayers()
for i = 1, #players do
        local player = players[i]
        player.TeamColor = BrickColor.new("Medium stone grey")
end
-- Changes players team back to old team
        mapChosenClone:Destroy()
    else
        h.Text = "There needs to be more than 1 player to start"
    end
    wait(1)

end
-- removes map and if there is less than 2 players it will make the hint say so.

Issue: All players are put on one team Help would be appreciated!

0
Hey, I'm on mobile and can't help tonight but please fix your code indentation to make it easier to read. AZDev 590 — 8y
0
That better? DesiredRep 75 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I think on line 20 you meant:

if i % 2 == 0 then

because 1 % 2 will be constant all iterations ._.

0
Thanks for the fix DesiredRep 75 — 8y
Ad

Answer this question