#help with kill leaderstats
25 messages · Page 1 of 1 (latest)
where is code 😂
CODe
** You are now Level 3! **
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
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)
no a number value works the same
test it
in studio
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...
idk if theres a diffrence
me sowwy
i accept sorgy
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)