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

How can I capture a KO and use that towards a leaderboard?

Asked by 8 years ago

So I've made it when a player dies their "level" in the leaderboard goes down. How would I make it so if they kill someone it would go up? I've tried playing around with other ko leaderboard scripts but I cant seem to get it to work. Here's my code:

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    local level = Instance.new("IntValue")
    level.Name = "Level"
    level.Value = 0
    level.Parent = leaderstats
end)


game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            local level = player.leaderstats.Level
            level.Value = level.Value - 1 
        end)
    end)
end)
0
a question ive been dying to get answered bubbaman73 143 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
        How is the player killing other players? If the player is using a sword for instance, then you would add the code into the sword around where the sword takes health away from the other player. Basically, you would have to place the code into the item you're using to kill other players and if that sword/gun kills the player, you would then add a point to the player using the weapon.

Hope I helped a little in your problem! Good luck.

0
If I am using a sword, how would the sword detect that it has killed the player; All swords do is damage. TheScriptingAccount 90 — 8y
0
You would check the health of the person the sword took damage from. You would check their Humanoid.Health value and if it = 0 than you would add a point to the local players leaderstats. User#11440 120 — 8y
Ad

Answer this question