Hi. I'm attempting to create a script that auto assigns a new player to join the losing team. However, I don't fully know how to do this. I've done calculating the KDR of one player, but how to I work out the KDR of the WHOLE team instead of 1 player?
Here is what I done so far:
function checkteams()
for i, v in pairs, game.Players:GetPlayers() do
if v.TeamColor == "Bright blue" then
kills = v.leaderstats.KOs.Value
deaths = v.leaderstats.Wipeouts.Value
kdr = (kills/deaths)
if v.TeamColor == "Bright red" then
kds = (kills/deaths)
end
end
end
end
game.Players.PlayerAdded:connect(function(plr)
if Workspace.MapHolder:GetChildren()[1] then
checkteams()
if kds > kdr then
plr.TeamColor = BrickColor.new("Bright red")
v:LoadCharacter()
elseif kdr>kds then
plr.TeamColor = BrickColor.new("Bright blue")
v:LoadCharacter()
end
end
end)
Thank you.

2 comments
Oops, thank you. I got a bit confused with the for i,v in pairs since I now usually use for i,v in next.
Heh, no problem.