I don't know how to explain in such few words, but basically what my script does is that whenever the player presses E and a humanoid is touching the Handle of the tool, it damages him, the problem is that you can just spam E and damage the Humanoid alot while still in the attack animation, does anyone know how to fix it?
--\ The Script //--
--\\ VARIABLES //--
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local swing = Enum.KeyCode.E
local spin = Enum.KeyCode.Q
local damage = 0
--\\ SWING //--
function swing(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
damage = 15
script.Parent.Touched:Connect(function(part)
wait(.7)
if part.Parent:WaitForChild("Humanoid") then
part.Parent.Humanoid:TakeDamage(damage)
damage = 0
end
end)
end
end
UserInputService.InputBegan:Connect(swing)
Any help?

1 comment
I've tried it but it still doesn't stop it from attacking when spamming E. Thanks for the effort tho!