How can I make players change team using a script? I want it to change the players team, then respawn them. Help please!
EDIT:
People said this question was vague. Sorry about that.
In my game, called "the temple" (for now) after a player conquers the temple, it changes that person to spectators team and the game starts over. Then all the 4 players and changes to the "players" team (again, a better name will be assigned later) they are then respawned. Then they are given a sword. I can write the rest. Can someone write the code up to the point I just described?
In order to change the team a player is on, you need to change the TeamColor property (of the player.)
This is how it's done:
function setTeam(player, teamName) player.TeamColor = game.Teams[teamName].TeamColor if player.Character then --Just in case the character doesn't exist for some reason player.Character:BreakJoints() -- Kills the players' character end end --How it's used setTeam(game.Players.anth4598, "Blues") --Changing everyone's team to "Reds" for _, player in pairs(game.Players:GetPlayers()) do setTeam(player, "Reds") end
Tell me how that goes.
This question is extremely vague.
First off, if you are wanting an automatic team change then you can do this:
local team = "TEAM NAME" game.Players.PlayerAdded:connect(function (newPlayer) newPlayer.TeamCoor = BrickColor.new(game.Teams:FindFirstChild(team).TeamColor) if newPlayer.Character then newPlayer.Character.Humanoid.Health = 0 end end)
Is that what you mean't? If not, please explain more.
Locked by JesseSong
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?