Animation fix wait

and so hello everyone, I would like to add animation delay, I can’t add it myself because the script is not my level

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14717519545"
local track

 tool.Activated:Connect(function()
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = false
track:Play()
wait(1)
end)
tool.Unequipped:Connect(function()
if track then
	track:Stop()
end
 end)

please help kind people please any help will be useful help to fix this damn script already

Do do this add a task.wait() at the beginning of the activation function, not the end.

I improved a few other parts of your script as well:

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14717519545"
local track

tool.Activated:Connect(function()
task.wait(desired_delay_time)
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = false
track:Play()
end)

tool.Unequipped:Connect(function()
if track then
	track:Stop()
end
 end)

Basically the big thing I changed is I changed wait() to task.wait(). It is a more performance friendly method of yielding scripts.

Congrats on beginning your scripting journey!

Screenshot_1

I want to add an animation delay, otherwise it will quickly release it.

hey man, you need to put your delay time like, task.wait(1) or task.wait(“1”)

1 Like

I want to add an animation delay, otherwise it will quickly release it. pls help me

how much delay do you want? like how many seconds?

2 seconds will be enough it will be very good

so try this:

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14717519545"
local track

tool.Activated:Connect(function()
    wait(2) -- DELAY TIME 2 SECONDS YOU CAN CHANGE IT
    track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
    track.Priority = Enum.AnimationPriority.Action
    track.Looped = false
    track:Play()
end)

tool.Unequipped:Connect(function()
    if track then
        track:Stop()
    end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.