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

How come my team switch script doesn't work properly?

wait(5)
game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            player.TeamColor = BrickColor.new("Really blue")
        end)
    end)
end)

I have this script which switches players teams from Bright blue to Bright red after 5 seconds. The players get switched to Bright red but errr, after they die they dont switch back to Bright blue. :/ And Bright blue is set as an auto assignable team. Help anyone? :/

3 comments

0

Why does the code say "Really black" if the color is "Bright blue" :|

0

The bright blue spawn shouldn't be auto assignable if I remember correctly. I think all spawns need to be autoassignable false and you need to make your own team assignment system. so basically when the player joins you set their team with the script then change it when they die. Also make sure that their team is not neutral.

0

Use "@AZDev" to send a notification to me if you have further questions.

1 answer

✓ Accepted answer

Maybe try and make it so it actually goes to the BRIGHT BLUE team, not the really black.

This code should work

while true do
player = script.Parent.Parent.Parent
char = player.Character
humanoid = char:findFirstChild("Humanoid")
team1 = game.Teams["TEAM1"]-- First team
team2 = game.Teams["TEAM2"] -- Team you want to change


function change()

if player.TeamColor == team1.TeamColor then
player.TeamColor = team2.TeamColor
elseif player.TeamColor == team2.TeamColor then

end
end
wait(2)
humanoid.Died:connect(change)
wait(2)
end 

Put the script in ScreenGui and make sure you put it with a ScreenGui or it won't work. Fill in the teams or it won't work as well. It's the team's name and it's case sensitive so make sure you do it like I put in script!

Hope it helps! Make sure to accept my answer if this helped you out! :)

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