I don't know why, but even if I am not pressing "Q", it can hit a humanoid when it's right hand or left hand is near the humanoid
local pressed = false
local trackanimation = nil
local playability = true
local hold = false
local value = script:GetChildren("PunchVal")
value = 1
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Q and not pressed then
if playability == true and value == 1 then
pressed = true
local plr = game.Players.LocalPlayer
trackanimation = plr.Character.Humanoid:LoadAnimation(animation1)
trackanimation:Play()
wait(0.7)
pressed = false
value = 2
playability = false
local Debounce = false
local plr = game.Players.LocalPlayer
plr.Character.RightHand.Touched:connect(function(hit)
if hit.Name ~= "Skill" then
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid and humanoid ~= plr.Character.Humanoid then
if Debounce == false then
Debounce = true
wait(1)
script.Punch1Sound:Play()
humanoid:TakeDamage(1)
Debounce = false
if humanoid:TakeDamage(1) then wait(0.8)
end
end
end
end
end)

2 comments
The debounce should be at the first line after the event statement.
Now, it doesn't hits more than once, but this time, it hits even if I ain't pressing "Q".