Script animation is not working

I’m trying to make a forsaken-like game and when i click the gui element its supposed to play an animation and enable a script.

The script enabling part works, but it isn’t animating

I’ve trying making the animation priority higher and reuploading the animation, but it isnt working.

wait(0.1)
local Animator = workspace:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name):FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local Cooldown = script.Parent.Parent.Cooldown
local AnimatioN  = script.Parent.Parent.Flop

script.Parent.MouseButton1Click:Connect(function() 
	if Animator then
		if Cooldown.Value == 0 then
			Animator.Parent.WalkSpeed = 0
			wait(0)
			Cooldown.Value = 15
			local anim = Animator:LoadAnimation(AnimatioN)
			anim.Priority = Enum.AnimationPriority.Action2
			wait(0.6)
			Animator.Parent.Parent:FindFirstChild("StompBoxScript").Enabled = true
			wait(0.1)
			Animator.Parent.WalkSpeed = 23
			Animator.Parent.Parent:FindFirstChild("StompBoxScript").Enabled = false
	else
		print("Failed2")
	end
		
		
	else
		print("Failed")
	end
end)

did you forgot add anim:Play()?

:Play() method of the AnimationTrack will play the animation when called.
You also can use .Ended:Connect() when the Animation is stop playing.

if Animator then
	if Cooldown.Value == 0 then
		Animator.Parent.WalkSpeed = 0
		wait(0)
		Cooldown.Value = 15
		local anim = Animator:LoadAnimation(AnimatioN)
		anim.Priority = Enum.AnimationPriority.Action2
		anim:Play()
		wait(0.6)
		Animator.Parent.Parent:FindFirstChild("StompBoxScript").Enabled = true
		wait(0.1)
		Animator.Parent.WalkSpeed = 23
	else
		...
	end
else
	...
end

If It’s still not working, reply here

That worked, Thanks!

(letters for posting)

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