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

Would this team changing script work?

children = game.Players:GetChildren()

team1 = ("Bright blue")
team2 = ("Bright red")

children = team1 ("Bright blue")

if Player.Humanoid.Health = 0 then
	children = team2 ("Bright red")
end

2 answers

✓ Accepted answer

From my understanding, you want everyone to start on the blue team? And by some natural disaster or NPC, they go on the red team? If so, you'd need the Died event. If you want this to repeat, just put it in a while true do loop with a wait time of each round.

game.Players.PlayerAdded:connect(function(p)
	--p.TeamColor = BrickColor.new("Bright blue")
	--above is if you want it so when they join they go on that team. (Incase you don't have a script that sorts that out)
	p.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			p.TeamColor = BrickColor.new("Bright red")
		end)
	end)
end)

No you failed an If and Then statement.

children = game.Players:GetChildren()

team1 = ("Bright blue")
team2 = ("Bright red")

children = team1 ("Bright blue")

if Player.Humanoid.Health == 0 then
    children = team2 ("Bright red")
end

I didnt see anything wrong other than that.

1 comment

0

I can still see many flaws. You never accessed their teamcolor to change it to a BrickColor... Also, for line 8, you'd need a loop to repeat it because it needs to keep checking if they die. One more tip, sometimes, their health goes below 0 so it may be able to bypass line 8.

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