im trying to add delays to this local script on a tool the animations but idk how
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local tool = script.Parent
local swingsound = tool:WaitForChild("Swing")
local canattack = tool:WaitForChild("CanAttack")
tool.Activated:connect(function()
local choose = math.random(1,2)
canattack.Value = true
if choose == 1 then
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
swingsound:Play()
swing1animation:Play()
canattack.Value = false
elseif choose == 2 then
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
swingsound:Play()
swing2animation:Play()
end
end)
tool.Deactivated:connect(function()
canattack.Value = true
end)
tool.Unequipped:connect(function()
local hum = char:WaitForChild("Humanoid")
for _,anim in pairs(hum:GetPlayingAnimationTracks()) do
anim:Stop()
end
end)

1 comment
Add animation events to your animation. You can set debounces based on when those events are reached. https://developer.roblox.com/en-us/api-reference/function/AnimationTrack/GetMarkerReachedSignal