How could i make a simple kill all players and change teams script?

i want all the players to die using their humanoids to reset them, and then i want to set all their teams to a team called ‘Neutral’

the issue:
i dont know how to set the team and im not good at for i,v in pairs (or just in pairs i think) which im pretty sure is needed to look for all the humanoids

1 Like

Ok here we go!

-- // Variables //
local Players = game:GetService('Players') -- This is player service, it allows us to get players!
local Teams = game:GetService('Teams') -- This is the parent to all teams most of the time!

local TeamToSwapTo = Teams:FindFirstChild('YOUR_TEAM_HERE')

-- // Main Code //
for index:number,player:Player in pairs(Players:GetPlayers()) do -- this loops through the players, we use GetPlayers which uh, gets players
	-- GetPlayers returns a table, an item in a table contains an index, or key, or you can think of it as a name, then it has a value, which could be anything
	-- But we know that GetPlayers gives us a table of players, so the value is a player!
	-- the index, or key comes first, then the value. So in this case, key comes first, then player.
	
	-- now lets set some values!
	player.Team = TeamToSwapTo -- Sets the team property of the player to the team of your chose!
end

I tried to leave some notes to help, if you have any questions feel free to ask!

2 Likes

thank you! ill make sure to get back to you if something is wrong!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.