I added a feature that gives the player 1 kill every time they kill someone but it would not work
Damage script:
local gear = script.Parent
local hitbox = script.Parent.Hitbox
local damage = 50
local canDamage = script.Parent.canDamage
hitbox.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildWhichIsA('Humanoid')
if canDamage.Value == true then
hum:TakeDamage(50)
canDamage.Value = false
end
end)
leaderstats script:
local dataStores game:GetService("DataStoreService"):GetDataStore("KnifeBattlesDataStore")
game.Players.PlayerAdded:Connect(function(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
local gems = Instance.new("IntValue")
gems.Name = "Gems"
gems.Value = 0
gems.Parent = leaderstats
--Data Stores
local killsData, gemsData
local succes, errormessage = pcall(function(player)
killsData = dataStores:GetAsync("Kills-"..player.UserId)
gemsData = dataStores:GetAsync("Gems-"..player.UserId)
end)
if succes then
if killsData then
kills.Value = killsData
gems.Value = gemsData
end
end
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
dataStores:SetAsync("Kills-"..player.UserId,player.leaderstats.kills.Value)
dataStores:SetAsync("Gems-"..player.UserId,player.leaderstats.gems.Value)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
kills.Value = kills.Value + 1 --This is the reward after the player died.
end
end
end)
end)
end)
end)
end)

2 comments
it now says there is a Infinite yield possible on 'Workspace.Player1.CoolBoyHair:WaitForChild("Humanoid")'?
In that case, try hit.Parent.Parent:WaitForChild("Humanoid")