I need help on making a kill detah leaderboard

Hello I am Devcycle recently I have been trying to make a kill death leaderboard for my game but when I script it it shows and error heres my code if you can help pls do its not finished.

3 Likes

Create a database where you can hold the kills

[Edit]: Might wanna show your error message in the logs

1 Like

You need to make sure you have the correct number of end as well as make sure your code is within the correct block so that it works properly. Additionally, there is no need to use repeat-until to get the humanoid because WaitForChild exists. Once you sort that out, it’s all about tagging the Humanoid of the person that was killed with the name of the player that damaged them when they died.

1 Like

One of the many problems here is that you need to properly indent your code. Another thing is that a lot of the variables and nested events you’re using is outside of the PlayerAdded event.

game:GetService("Players").PlayerAdded:Connect(Player)
    local Leaderstats = Instance.new("Folder")
    Leaderstats.Name = "leaderstats"
    Leaderstats.Parent = Player

    local Kills = Instance.new("IntValue")
    Kills.Name = "Kills"
    Kills.Parent = Leaderstats

    local Deaths = Instance.new("IntValue")
    Deaths.Name = "Deaths"
    Deaths.Parent = Leaderstats

    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        Humanoid.Died:Connect(function()
            Deaths.Value = Deaths.Value + 1
        end)
    end)
end)

For a brief rundown on the code, I basically edited yours so that the nested event was inside the code, and I also fixed a lot of the “end” statements in the code to the correct areas.

1 Like

Thank you everyone who helped me on this.