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

How can I check if a player from a certain team dies?

I have two teams, one team only has a single player and I want a script that will constantly check if that player in the Bright red team has died. I have a little something but I know it is wrong and I do not know where to go, I was hoping someone could hack something up for me, or at least the initial bits.

while true do
wait()
for i, v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new("Bright red") then
local character = v.Character
if character then
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
end)
		
		end
	end
end

	player.CharacterAdded:connect(function(character)	
		
	
	
end)

end

I KNOW, THE CODE IS WRONG/SLOPPY. I really need help, I want it to essentially isolate

Game.Players.PlayerAdded:connect(function(Player) --When a Player joins
    Player.CharacterAdded:connect(function(Character) --When they respawn
        Character.Humanoid.Died:connect(function() --When they die
             Player.TeamColor = team2.TeamColor --Put them on the 'Aliens' team
        end)
    end)
end)

but only for a player in the Bright Red team

1 answer

game.Players.PlayerAdded:connect(function(Player)
	Player.Neutral = false
	Player.TeamColor = 'Bright red'
	Player.CharacterAdded:connect(function(Character)
		Character:FindFirstChild'Humanoid'.Died:connect(function()
			if Player.TeamColor == 'Bright red' then
				Player.TeamColor = BrickColor.new'PutColorHere'
					elseif Player.TeamColor == 'PutColorHere' then
						return
						end end) end) end)

Why I did what I did: For the reason of ease, it's easier to just call the color by BrickColor.new() then to just make it copy the color of the team imo. (in my opinion.)

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