Ok so I am making a script that waits for 4 at least 4 people to be on the server, then assigns the players to be either "sharks" or minnows" at a 1:1 ratio. it doesn't seem to be working, when i simulate a game in studio with 4 players all the players spawn in the lobby on my "lobby" team and just stay there and are not assigned or respawned. what is wrong with my code? P.S. some background on my setup: I have a lobby with some white spawns for the lobby team. I have one red and one blue spawn outside the lobby, but i have not created the red or blue teams yet, they are supposed to be created in the code.

local function Start()--the function triggered when 4 players join
Shark_Team = Instance.new("Team",game.Teams) --Create two non neutral teams, sharks and minnows
Shark_Team.Name = "Sharks"
Shark_Team.TeamColor = BrickColor.new("Really red")
Shark_Team.AutoAssignable = false

Hum_Team = Instance.new("Team", game.Teams)
Hum_Team.Name = "Shark Bait"
Hum_Team.TeamColor = BrickColor.new("Electric blue")
Hum_Team.AutoAssignable = false

Lob_Team = game.Teams.Dead

Sharks = 0 -- assign players into 2 even teans
Mins = 0
for _,a in pairs(game.Players:GetChildren()) do
if a.Playing.Value then
if Sharks<=Mins then
a.Team.TeamColor = BrickColor.new("Really red")
Sharks = Sharks+1
elseif Mins+1<=Sharks then
a.Team.TeamColor = BrickColor.new("Electric blue")
Mins = Mins+1
else
if math.random(1,2)==2 then
a.Team.TeamColor = BrickColor.new("Really red")
Sharks = Sharks+1
else
a.Team.TeamColor = BrickColor.new("Electric blue")
Mins = Mins+1


for _,v in pairs(game.Players:GetPlayers()) do --respawn all players
v:LoadCharacter()
end

end end end end end


p = game.Players:GetChildren() --code to check if 4 people are on and then trigger the above function
while #p < 4 do
	game.StarterGui.Player_req.Frame.TextBox.Text = "4 Players are required to begin!"
	Player_Min = false
	wait(1)
end
while #p > 4 do
	game.StarterGui.Player_req.Frame.TextBox.BackgroundTransparency=1 
	Player_Min = true	
	wait(1)
end

if Player_Min == true then
wait(3)	
	Start()
end