Is there something wrong in this?
h = script.Parent:GetChildren("Humanoid") if h.Health = 0 then script.Parent.Parent.TeamColor = BrickColor.new("White") end
h = script.Parent:FindFirstChild("Humanoid") --First error. You need to search for a specific name, so use FindFirstChild. h.Died:connect(function () --The if function will only run once. This runs every time your character dies. game.Players:FindFirstChild(script.Parent.Name).TeamColor = BrickColor.new("White") --You tried to access the workspace. end)
I'm Aurum, and you're welcome.
The problem with that is that you're using an if statement without some sort of loop. This will onlt check once, and that is when the script is first processed. And there is no cjhance of the player being dead yet so what you have to do is wait for them to die by repeatedly checking or using the Died event. I prefer the latter.
h = script.Parent:FindFirstChild("Humanoid") h.Died:connect(function() script.Parent.Parent.TeamColor = BrickColor.new("White") end)
Also, you may want to check your methods of accessing the player and their humanoid because that doesn't look right. And 'GetChildren' should be replaced witrh FindFirstChild if it's not already incorrect.
-Goulstem
You can do this with the Died event The died event runs when a player dies for example
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name .. " has died!") end) end) end)
Prints the players name that died. For example.If i died the output would print Iluvmaths1123 has died! Now here is the script
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() script.Parent.Parent.TeamColor = "White" end) end) end)