Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is wrong with my team change script?

This script was used for my team change when dead.

game.Players.PlayerAdded:connect(function(plr)
plr.Neutral = false
plr.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()

if plr.TeamColor ==  BrickColor.new("Bright red") then
plr.TeamColor =  BrickColor.new("Bright Blue")
else
plr.TeamColor = BrickColor.new("Bright red")
end
end)


end)


end)

The problem is, whenever you die. It creates a new team called "Neutral" when they die. Does anyone know the problem?

1 answer

✓ Accepted answer

Team1 = game.Teams.Red
Team2= game.Teams.Blue
game.Players.PlayerAdded:connect(function(plr)
plr.Neutral = false
plr.CharacterAdded:connect(function(character)
plr.Neutral = false
character:WaitForChild("Humanoid").Died:connect(function()

if plr.TeamColor ==   Team1 .TeamColor then
plr.TeamColor =   Team2.TeamColor 
else
plr.TeamColor =  Team1.TeamColor 
end
end)


end)


end)

everytime player spawns set there Neutral edit: if team Dosent exist then it will be set to Neutral If code dosent work COmment below

9 comments

0

It still creates a team called "Neutral".

0

I will look into it

0

Two teams exist. Red & Blue. I want them to change to blue when they die. But it creates a team called "Neutral" when a player dies.

0

I updated the script make sure ur teams are called Red and Blue unless you change line 1 and 2

0

Red Team & Blue Team? Or just Red & Blue?

0

Just Red and JUst Blue

0

Okay, thanks! It worked :D One up.

0

you change the names by changing line 1 and line 2 at the end

0

and upvote me please

This discussion is preserved as it was. New answers, comments, and votes are closed.