Hey! I’m trying to fix a bug in one of my game which is a team bug, what i mean is when a round start, the half of the players will be Red and the other Blue to have 2v2, 3v3 ect.
Unfortunately the game make the game 3v1.
So the code is pretty simple.
I did a function to grab the half of the players and when i print it, it shows 2 when there are 4 players in the game. But when i do math.random(Half, PlayersInServer) the game will be 3v1.
Here’s the code :
function BlueAndRed()
local Half = getHalf()
local Red = {}
local Half = getHalf()
local Blue = game.Players:GetPlayers()[math.random(Half,#game.Players:GetPlayers())]
for i, players in pairs(players:GetChildren()) do
if players ~= Blue then
table.insert(Red, players)
players.TeamColor = game.Teams.Red.TeamColor
end
end
end
Thanks if you can help me!