Hello! I got slight issue with script. If i kill NPC the kill will not change in leaderstats +1 Kill (it does nothing)
Here is first script : (its called KillCredit2 on photo)
– i put it in ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new(“Folder”)
stats.Name = “leaderstats”
stats.Parent = plr
local kills = Instance.new(“IntValue”)
kills.Name = “Kills”
kills.Parent = stats
local deaths = Instance.new(“IntValue”)
deaths.Name = “Deaths”
deaths.Parent = stats
plr.CharacterAdded:connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild(“Humanoid”)
wait()
until humanoid
humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild(“creator”)
if tag then
local killer = tag.Value
if killer then
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
end
end
end)
end)
end)
Here is second one i tried : (in photo its called KillCredit)
local hum = script.Parent.Humanoid
hum.Died:Connect(function()
local tag = hum:FindFirstChild(“creator”)
if tag then
local player = tag.Value
local kills = player.leaderstats.Kills
kills.Value = kills.Value + 1
end
end)
None of them worked can someone help how it will work?