Hey there!
I am trying to create a system for my game where there is a certain amount of teams, and the sever script is supposed to share the players out between these teams (there is 2 teams right now)
I have made a small script in my module to see if this will work but when i test with multiple players, it adds them all to the same team, here is the script:
function module:setTeams()
for i,v in pairs(game.Players:GetPlayers()) do
local players = #game.Players:GetPlayers()
local team1 = game.Teams.Blue
local team2 = game.Teams.Red
local playersiterated = 0
for i = 1,players do
playersiterated+=1
if #team1:GetPlayers() >= #team2:GetPlayers() then
v.Team = team1
else
v.Team = team2
end
end
end
end
Any help is greatly appreciated!
(I also couldn’t find any videos or DevForum posts related to this topic.)