I am making a sword that has a killstreak feature, each time you get a kill, the Intvalue called "Kills" value change by 1 but It appears to get a extra 3 kills, wondering why

Script (Server):

local Tool = script.Parent
local SoundFolder = Tool.Sounds
local SlashAttack
local Boolens = {
	Debounce = false,
	CanDamage = false
}
local Animations = { ---Oh boi there Is alot
	EquipAnimation = Tool.EquipAnimation,
	Idle = Tool.Idle,
	Slash = Tool.Slash,
}

Tool.Equipped:Connect(function()
	SoundFolder.Unsheath:Play()
	local Humanoid = Tool.Parent.Humanoid
	
	local EquipAnimationTrack = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.EquipAnimation)
	EquipAnimationTrack:Play()
	task.wait(0.30)
	local Idle = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.Idle)
	Idle:Play()
	Tool.Unequipped:Connect(function()
		Idle:Stop()
	end)
end)

Tool.Activated:Connect(function()
	if not Boolens.Debounce then
		Boolens.Debounce = true
		Boolens.CanDamage = true
		SoundFolder.Slash:Play()
		print("The tool has been clicked")
		local Humanoid = Tool.Parent.Humanoid

		SlashAttack = Humanoid:FindFirstChild("Animator"):LoadAnimation(Animations.Slash)
		SlashAttack:Play()
		task.wait(0.5)
		Boolens.CanDamage = false
		wait(1)
		Boolens.Debounce = false
	end
end)

Tool.Handle.Touched:Connect(function(hit)
	local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if Player then
		local player1 = game.Players:GetPlayerFromCharacter(Tool.Parent)
		local player2 = game.Players:GetPlayerFromCharacter(hit.Parent)

		if (player1 ~= nil) and (player2 ~= nil) then
			local humanoid = (player2.Character or player2.CharacterAdded:Wait()):FindFirstChildWhichIsA("Humanoid")

			if (player1.TeamColor ~= player2.TeamColor) then
				if (humanoid ~= nil) and Boolens.CanDamage == true then
					Boolens.CanDamage = false
					humanoid:TakeDamage(30)
					humanoid.WalkSpeed = 10
					humanoid.JumpPower = 30
					wait(5)
					humanoid.WalkSpeed = 16
					humanoid.JumpPower = 50
					if humanoid.Health == 0 then
						SoundFolder["Kill Get"]:Play()
						Tool.Kills.Value = Tool.Kills.Value + 1
					end
				end
			end
		end
	else
		local NPCHumanoid = hit.Parent:WaitForChild("Humanoid")
		if NPCHumanoid and Boolens.CanDamage == true then
			Boolens.CanDamage = false
			NPCHumanoid:TakeDamage(30)
			NPCHumanoid.WalkSpeed = 10
			NPCHumanoid.JumpPower = 30
			wait(5)
			NPCHumanoid.WalkSpeed = 16
			NPCHumanoid.JumpPower = 50
			if NPCHumanoid.Health == 0 then
				SoundFolder["Kill Get"]:Play()
				Tool.Kills.Value = Tool.Kills.Value + 1
			end
		end
	end
end)

1 comment

0

try placing  if humanoid.Health == 0 then above the wait