Hi guys, I’m here again to ask for a little help from you, I would like it on the Learder Board so that with each kill that the player makes, almente +1 in his rank and so on, but the rank appears correctly but does not raise the player’s rank after the kill.
That’s my script and that’s how the game performs:
No matter how many times I kill the player, the rating doesn’t increase.
Here is the free script code for modification:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local kills = Instance.new("IntValue", leaderstats)
kills.Name = "Kills"
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function(killer)
if killer and killer.Character and killer.Character:FindFirstChild("Humanoid") then
local killerHumanoid = killer.Character:FindFirstChild("Humanoid")
if killerHumanoid and killerHumanoid.Health > 0 then
player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
end
end
end)
end)
end)
I am very grateful to anyone who can help me 
The Died
signal does not return a killer
argument.
You need to track your own killers. You can do it however you want, or you can follow the old method of adding an ObjectValue
named creator
inside the Humanoid
. Most of roblox’s old gear (including official ones) follows this schema to keep track of killers. This way, this is compatible with other gears that supports the creator
tag.
-- somewhere in your damage script
local function addCreatorTag(toHumanoid: Humanoid, fromPlayer: Player): ()
local creator: ObjectValue? = toHumanoid:FindFirstChild("creator") :: ObjectValue
if creator ~= nil and creator.Value ~= fromPlayer then
creator:Destroy()
creator = nil
end
if creator == nil then
creator = Instance.new("ObjectValue")
assert(creator ~= nil)
creator.Name = "creator"
creator.Value = fromPlayer
creator.Parent = toHumanoid
end
end
humanoid:TakeDamage(someDamage)
addCreatorTag(humanoid, shootingPlayer)
humanoid.Died:Connect(function(): ()
local creator: ObjectValue? = humanoid:FindFirstChild("creator") :: ObjectValue
if creator ~= nil and creator.Value ~= nil and creator.ClassName == "Player" then
local killer: Player = creator.Value :: Player
-- your code here
end
end)
3 Likes
Thank you, I will test later, but in this case do I need to replace my script or create a new one and use yours?