Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

a question ive been dying to get answered

1 answer

        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.

2 comments

0

If I am using a sword, how would the sword detect that it has killed the player; All swords do is damage.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.