Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with awarding points on death?

Asked by 10 years ago

The script below detects if a player has died and if they have award them points, it works, but if your on green team and you kill a yellow player the yellow player gets the exp. How can I change this so the green player gets the exp?

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid")
        character.Humanoid.Died:connect(function()
            if character.Humanoid:FindFirstChild("creator") then
                local tag = character.Humanoid.creator
                local tColor = player.TeamColor
                local kColor = tag.Value.TeamColor
                if not kColor then return end
                if not tColor then return end    
                if tColor ~= kColor then
                    if kColor == BrickColor.new("Lime green") then
                        player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 100
                    elseif kColor == BrickColor.new("New Yeller") then
                        player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 100
                    end
                end
            end
        end)
    end)
end)

Answer this question