Currently trying to make a combat system with .Touched and having trouble "debouncing" with the event.
script.Parent.Activated:Connect(function() if not debounce then debounce = true if combo == 0 then combo = 1 newHitbox = hitbox:Clone() newHitbox.Parent = myHumanoidRootPart newHitbox.CFrame = myHumanoidRootPart.CFrame debris:AddItem(newHitbox, 0.9) local weld = Instance.new("Weld") weld.Parent = newHitbox weld.Part0 = newHitbox weld.Part1 = myHumanoidRootPart newHitbox.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then print("Hit") end end) combo = 0 end debounce = false end end)
I've tried adding a debounce within the touched event itself and that didn't work either.
It'll essentially detect all the players' body parts pritning "Hit" 7 times rather than 1.
You just need to add a wait(duration) before setting the debounce back to false. Currently, you're setting the debounce to true then almost immediately setting it back to false.
To build upon what Crimsonicacy said, you need to add a wait to it because as soon as the event fires, you're setting it to true then immediately back to false. Also, however, you need to move the debounce into touched event itself, or setup a second for the touched event, as the debounce outside of it won't have any effect on it as is meaning it is still reading it as every single part that touches it will pass through.