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

How do I fix this random team script?

Asked by
PWNTART 33
9 years ago

After the first time it stops making teams even and makes it like AllPlayers VS 0 players

local teams = {"Really red","Really blue"}

local config = script.Configuration

game.Players.PlayerAdded:connect(function(player)
 if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then

player.Chatted:connect(function(chatmsg)
                if chatmsg:sub(1,9) == "Randomize" then

local players = game.Players:GetChildren()
for i = 1,#players do
local ChosenTeam = teams[math.random(1,#teams)]

   players[i].TeamColor = game.Teams:findFirstChild(ChosenTeam).TeamColor -- Picks one of the brick colors out of the teams table
end
end
end)
end
end)
0
Please place your script in a code block. M39a9am3R 3210 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Try putting math.randomseed(tick()), doing this will make the random numbers even more random, so to speak, otherwise you may find patterns. Add this to an lines previous to line 13, preferrably at the beginning of the script.

math.randomseed(tick())
0
No didnt really do much. Found a pattern but then it stopped PWNTART 33 — 9y
Ad

Answer this question