Hello. For a gamemode I’m creating, I need a little help with something. You see, what this part of the code is supposed to show is to:
Get the players on both teams.
When a player dies, they move to the spectator team.
If the spectator team is full of all the players on one team, it says that the other team won, then generates a mapchange(for now mapchange has been replaced with ply:ConCommand).
Here’s the code(I’m not having an error with it, but instead I just don’t know how to get it to work the way I want it to):
function GM:PlayerDeath( ply, ent, att ) timer.Simple( 0, function() if ply:IsValid() then ply:SetTeam( TEAM_SPECTATOR ) ply:Spectate( OBS_MODE_ROAMING ) if team.NumPlayers( TEAM_SPECTATOR) == #team.GetPlayers then PrintMessage( HUD_PRINTTALK, "One team has been eliminated! Round over." ) timer.Simple( 10, function() ply:ConCommand("respawn_entities") end ) end end end) end
Edit: The two teams I’ve created are called “Rebels” and “Combine” and their team numbers(not indexes) are (For Combine): 1, and(For Rebels): 2.