So I am making a pretty simple game. A countdown plays and then all players are separated into two and each half is put into different teams and given different weapons.
The problem is I don’t know how to actually do this. How can I get all of the players. and how can I split them in half and then edit them individually?
I haven’t tried anything since I don’t know where to start.
this code below will separate the players into two teams
local waittime = 10
local half = #game.Players:GetChildren()/2 -- gets half of the players
local team1 = {nil} -- defines the first team
local team2 = {nil} -- defines the second team
wait(waittime)
for i,player in pairs(game.Players:GetChildren()) do -- loops through all the players
if i <= half then -- checks if there has been less than half the players
table.insert(team1,v)
--code for team 1 players
else -- checks if there has been more than half the players
table.insert(team2,v)
--code for team 2 players
end
end
print(team1,team2)