-
What do you want to achieve? a punch animation that’s un-spammable
-
What is the issue? Not really sure how to do it (here’s a video of it)
-
What solutions have you tried so far? I’ve tried looking around in the internet but nothing was helpful
here’s the code ( it has parts taken from other scripts and modified to work for me )
local canPunch = true
local CurrentlyPunching = false
local Keybind = "F"
local damage = 15
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
local anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Animation)
anim:Play()
CurrentlyPunching = true
wait(1)
CurrentlyPunching = false
end
end)
script.Parent.Parent.RightHand.Touched:connect(function(hit)
local model = hit:FindFirstAncestorOfClass("Model")
if model and model:FindFirstChild("Humanoid") and canPunch and CurrentlyPunching then
model:FindFirstChild("Humanoid"):TakeDamage(damage)
canPunch = false
wait(1)
canPunch = true
end
end)