#help with kill leaderstats

25 messages · Page 1 of 1 (latest)

livid verge
wheat mesa
#

where is code 😂

cinder lichen
#

CODe

ruby fjordBOT
#

studio** You are now Level 3! **studio

cinder lichen
#

uknow what

#

lemme make one for whatever reason

#

game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"

local Coins = Instance.new("NumberValue",leaderstats)
Coins.Name = "Coins"
Coins.Value = 0


while wait(1) do
    Coins.Value += 1
    
    if Coins.Value >= 20 then
        plr.Character.Humanoid.Health = 0
    
        
        
    end
end

end)

#

here is the most simple thing ever

#

!compile

lapis magnet
#

whatsa numbervalue

#

you mean IntValue?

#

that script works an

#

the one i gave ya

#
game.Players.PlayerAdded:Connect(function(plr)
    local leaderstats = Instance.new("Folder",plr)
    leaderstats.Name = "leaderstats"

    local Coins = Instance.new("IntValue",leaderstats)
    Coins.Name = "Coins"
    Coins.Value = 0


    while task.wait(1) do
        Coins.Value += 1

        if Coins.Value >= 20 then
            plr.Character.Humanoid.Health = 0
        end
    end
end)
cinder lichen
#

test it

#

in studio

lapis magnet
#

well its the same thing they both work i just don't recognize number values

#

mb man ill never come back to help anyone, jeez...

cinder lichen
#

idk if theres a diffrence

cinder lichen
lapis magnet
#

i accept sorgy

deep fox
#

i was sleeping ;-;

#

local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Value = 0
kills.Parent = leaderstats

end

local function onHumanoidDied(victimHumanoid)
local creatorTag = victimHumanoid:FindFirstChild("creator")
if creatorTag and creatorTag.Value and creatorTag.Value:IsA("Player") then
local killer = creatorTag.Value
local killsStat = killer:FindFirstChild("leaderstats") and killer.leaderstats:FindFirstChild("Kills")
if killsStat then
killsStat.Value = killsStat.Value + 1
print(killer.Name .. " now has " .. killsStat.Value .. " kills.")
end
else
print("No valid killer found for Humanoid death.")
end
end

local function tagHumanoidWithKiller(targetHumanoid, attackerPlayer)
local existingTag = targetHumanoid:FindFirstChild("creator")
if existingTag then
existingTag:Destroy()
end

local creatorTag = Instance.new("ObjectValue")
creatorTag.Name = "creator"
creatorTag.Value = attackerPlayer
creatorTag.Parent = targetHumanoid

game:GetService("Debris"):AddItem(creatorTag, 2)
print("Creator tag added by:", attackerPlayer.Name)

end

game.Players.PlayerAdded:Connect(onPlayerAdded)

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
onHumanoidDied(humanoid)
end)
end)
end)