Gun not adding point to leaderstats

script.Parent.Handle.Touched:Connect(function(touch)

if script.Parent.CanDamage.Value == true then
	
	local humanoid = touch.Parent:FindFirstChild("Humanoid")
	
	if not touch.Parent:FindFirstChild("Humanoid") then 
		
		humanoid = touch.Parent.Parent:FindFirstChild("Humanoid")
		
	end
	
	if humanoid.Name ~= "Humanoid" then return end
	
	script.Parent.CanDamage.Value = false
	
	humanoid:TakeDamage(100)
	
	if humanoid.Health < 1 then
		
		local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
		plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
		
	end
	
	wait(1)
	
	script.Parent.CanDamage.Value = true
end

end)

when the gun kills it doesnt add 1 point to the kill leaderstats. anything i am doing wrong?

please someone help me with it.

Before anything since it looks like it should work, does the script error when trying it out?

maybe i will try. it i just changed the number of damage it takes.

Hmm, perhaps you could try something like this

script.Parent.Handle.Touched:Connect(function(touch)

	if script.Parent.CanDamage.Value then
		
		local humanoid
		
		if touch.Parent:IsA("Accessory") then
			humanoid = touch.Parent.Parent:FindFirstChild("Humanoid")
		else
			humanoid = touch.Parent:FindFirstChild("Humanoid")
		end
		
		if humanoid == nil then return end
		
		script.Parent.CanDamage.Value = false
		
		humanoid:TakeDamage(100)
		
		if humanoid.Health < 1 then
			local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
			plr.leaderstats.Kills.Value += 1
			
		end
		
		wait(1)
		
		script.Parent.CanDamage.Value = true
	end
end)

What this does is check if CanDamage is true, then, depending on if the thing that touches as an Accessory for a parent, tries to find the humanoid, and if it didn’t find anything and the variable is nil, return and don’t do anything afterwards. If it found a humanoid, then it damages them and if the health is less than 1, add a kill. Let me know if this works or not