Players = game:GetService("Players") Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") Humanoid.Died:connect(function() if Humanoid.TeamColor == "Bright blue" then game.Workspace.RedScore.Value = game.Workspace.RedScore.Value + 1 else game.Workspace.BlueScore.Value = game.Workspace.BlueScore.Value + 1 end end) end) end)
I made this script so that whenever a player dies, it checks their team, and if it's the blue team, a number value in workspace will go up by 1, and if it's the red team, a different number value in workspace will go up by 1. I have this script in serverscriptservice and I have tried different ways, one time it worked but only the red team score increased :/ at this point it doesn't work at all and shows me no errors in the output, anyone know why?
Explanation
In lua, ==
will also compare data type. Player.TeamColor
will return a BrickColor
(ikr damn americans). You are trying to compare that with a string
.****
EDIT:
There is also another problem, Humanoid.TeamColor
is not a property. You want to check Player.TeamColor
Solution
Instead of having line 6 compare Player.TeamColor
with a string like so:
if Humanoid.TeamColor == "Bright blue" then
It should compare it with the data type
of TeamColor
and it should be Player.TeamColor :
if Player.TeamColor == BrickColor.new("Bright blue") then
If this helped then please upvote and choose it as the answer!