Help with damage script

So im adding damage to my combat script, and i need help on an issue im having

im using a touched function, and added a debounce. But even so the damage is dealt when the player doesnt click.

What im asking is, how would i make it so damage is only dealt if the player clicks and the arms (eitehr left or right) are touching the hitbox?

I don’t think you would necessarily use a debounce in this situation, but instead, when the player clicks, it checks if the arms are touching the hitbox. If it is, then it will damage the player.

this could work yes, but even if the click ends the script will still check if the arms are touching the hitbox

Is this how you want it to act or is this how it acts right now? Sorry for asking so many questions.

Your question isn’t very clear — is it that your weapon deals damage simply when held and brushed against another player?

I suggest making the weapon also check whether it is currently being swung.
Before, your damage dealing script might look something like if debounce == false and isPlayer(hit) then dealDamage(hit) end.

You’d have to make it check for some sort of “swinging” variable (if debounce == false and swinging == true and isPlayer(hit) then dealDamage(hit) end), then set this variable to true when the player swings it and set it to false shortly afterward.
This way, the weapon will be harmless when it’s not being used to attack.

If your swinging and damaging scripts are separate, this becomes a bit harder, you have to mess with remoteevents (if there’s a localscript involved) or use a BoolValue to share the “swinging” state between scripts, but this is how you’d do it.