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

How do I reset Leaderboard after death?

Asked by 4 years ago

I still have a hard time understanding specific players on a normal script.

For a fighting game, I have a normal script that gives the killer a point if he/she kills the other opponent. I do know that for other players to be able to see the kills, the script will have to be a normal script.

I’m having lots of trouble understanding how to reset the kill count (leaderboard) for the killed player.

Here is my script that I’m using for the leaderboard.

local Players = game.Players


local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'

Instance.new('IntValue', Template).Name = "Kills"


Players.PlayerAdded:connect(function(Player)
    wait(1)
    local Stats = Template:Clone()
    Stats.Parent = Player



    Player.CharacterAdded:connect(function(Character)

        local Humanoid = Character:FindFirstChild "Humanoid"
        if Humanoid then
            Humanoid.Died:connect(function()
                for i, Child in pairs(Humanoid:GetChildren()) do
                    if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
                        local Killer = Child.Value


                        if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
                            local Kills = Killer.leaderstats.Kills
                            Kills.Value = Kills.Value + 1
                        end
                        return -- Only one player can get a KO for killing a player. Not 2, not 3. Only one.
                    end
                end
            end)
        end
    end)
end)

0
what do you mean? Mr_m12Ck53 105 — 4y
0
im trying to do (Kills.Value = Kills.Value - 5) if the player that got killed from the sword, then they lose 5 points ffancyaxax12 181 — 4y
0
but i dont know what to do ffancyaxax12 181 — 4y

Answer this question