The title is confusing, I know. I tried my best to explain it in one sentence.
I made a punch system. When you click it punches, although there is a slight problem I want to fix.
For some reason, my punch system is acting weird. Each time I click to punch, then touch someone with the arm I punched with, it will still damage them even though I punched them a while ago.
You can check the video below.
I don’t know how I could fix this or what the problem is in the script.
Damage portion of the script, this is all you need to know about the script, but if you want the full script then you can ask. I did this to keep the page clean
Normal script:
--<Damage>--
punchEvent.OnServerEvent:Connect(function(player, character)
db = true
character[attackingArm].Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= character.Name then
if db == true then
db = false
hit.Parent.Humanoid:TakeDamage(5 + statistics.Strength.Value)
local damageSound = Instance.new("Sound", hit)
damageSound.Name = "Hit"
damageSound.SoundId = hitSound
damageSound.PlaybackSpeed = playbackSpeed
damageSound.RollOffMinDistance = 5
damageSound.RollOffMaxDistance = 30
damageSound.Volume = 0.25
damageSound:Play()
local impactAttachment = Instance.new("Attachment", character[attackingArm])
impactAttachment.Position = Vector3.new(0, -1, 0)
local impact = script.Parent.Impact:Clone()
impact.Parent = impactAttachment
impact:Emit(1)
wait(0.5)
impactAttachment:Destroy()
impact:Destroy()
damageSound:Destroy()
end
end
end
end)
end)
I hope to find a solution. I appreciate it greatly if you could help!
Thanks!