Help with punch script

I have a strength simulation game and I made a punch, but when I attack someone or some dummy, for some reason more than one hit, if someone can help me with that I would be happy.

this is the script:

local DataStore2 = require(1936396537)

DataStore2.Combine("GameData_V1","PowerModV_1","Power")

local Punch = script.Parent
debounce = false
DebaunceDamage = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")

HandDMG = "LeftHand"

function SetHand ()
if HandDMG ~= "LeftHand" then
	HandDMG = "LeftHand"
elseif HandDMG ~= "RightHand" then
	HandDMG = "RightHand"
end
end

function ChangeHealth (HitedHum,TakeDmg)
if HitedHum.Health > 0 then
HitedHum:TakeDamage(TakeDmg)
	if HitedHum.Health <= 0 then
		local GiverEvent = HitedHum:FindFirstChild("GiverEvent")
		if GiverEvent then
		                            
ReplicatedStorage.Events.Giver_Event:Fire(Punch.Parent.Name,HitedHum.Parent.Name)
		end
	end
end
end

Punch.Activated:Connect(function()
if not workspace:FindFirstChild(Punch.Parent.Name) then return end
if debounce then return end
	
local player = game.Players[Punch.Parent.Name]	
debounce = true

local PlayAnimation = 
Punch.Parent.Humanoid:LoadAnimation(script:WaitForChild(HandDMG))
PlayAnimation:Play()

PartToTouch = Punch.Parent[HandDMG]

if not DebaunceDamage and debounce then
PartToTouch.Touched:connect(function(hit)
if PartToTouch.Name ~= HandDMG then return end
if not DebaunceDamage and debounce then
DebaunceDamage = true

local TakeDmgPlayer = math.ceil((DataStore2("Power",player):Get(0)/47632)/50)
local TakeDmgDummy = DataStore2("PowerModV_1",player):Get(0)/1000000000000000

local HitedChar = hit.Parent
local HitedHum = HitedChar:FindFirstChild("Humanoid")

if HitedHum then
	if game.Players:FindFirstChild(HitedChar.Name) then
		if HitedHum.Health >0 and PartToTouch.PunchSond then
		PartToTouch.PunchSond:Play()
		end
		HitedHum:TakeDamage(TakeDmgPlayer)
	elseif HitedHum:FindFirstChild("GiverEvent") then
		if HitedHum.Health >0 and PartToTouch.PunchSond then
		PartToTouch.PunchSond:Play()
		end
		ChangeHealth(HitedHum,TakeDmgDummy)
	end
end
end
end)
end
PlayAnimation.Stopped:Wait()
debounce = false
DebaunceDamage = false
SetHand()
end)

(the script is inside a Tool [Punch])

1 Like