This is the code:
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() print(player.Name,player.Team,player.TeamColor) if player.Team == "Red" then _G.claimed = _G.claimed + 1 end
When I reset the game outputs my player name and my team/team brick colour as it's supposed to (Line 4).
The team name it outputs is "Red".
The if statement says if the player is on red add a point. (Of course this only happens when the player dies)
My problem is that it for some reason doesn't add the point. If I remove the if statement it works but it'll give the point even if blue dies (I only want to add the point if red dies).
How can I make this work?
This should work I think.
game.Players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder",player) folder.Name = "leaderstats" local currency1 = Instance.new("IntValue",folder) currency1.Name = "Points" player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() local tag = character.Humanoid:FindFirstChild("creator") if tag ~= nil then if
I figured it out.
Instead of checking if they are in red team by doing:
if player.Team == "Red" then
You shouldn't use a string. So, it worked by doing this:
local RedTeam = game.Teams.Red if player.Team == RedTeam then