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

What am I doing wrong?(Still unanswered)

Ok so I made it so that my you started out on one team but if you were killed then it would take you to the other. And that worked. But then I realized since I wanted the map/players to reset after the round that they would only be on the right team once(the first time they spawned) So this is my script to make it spawn on the blue team every time the round began but it didn't work.

function respawn()
for i,v in pairs(game.Players:GetPlayers()) do
    v.Character.Humanoid.Health = 0
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
c:WaitForChild("Humanoid").Died:connect(function()
p.TeamColor = BrickColor.new("Bright Blue")
end)
end)
end)
c:WaitForChild("Humanoid").Died:connect(function()
p.TeamColor = BrickColor.new("Bright Orange") 
end)
end

Any help. Thanks

2 comments

0

Does it make the players change to the orange team instead?

0

It would usually change them to orange once they die but I dont want that to happen when it resets the map.

1 answer

The issue to your problem is that you have two functions that determine the team the player joins on death of the humanoid. This causes the "Bright Orange" function to run after the "Bright Blue" function. the easiest way to work around this is to simply replace:

c:WaitForChild(Humanoid).Died:connect(function()
p.TeamColor = BrickColor.new("Bright blue")
end)

With:

p.TeamColor = BrickColor.new("Bright blue")

"Blue" and "Orange" also cannot be capitalized.

1 comment

0

What do you mean by add in the respawn function?

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