The script I have plays an animation in an NPC named Martin. After 3 seconds, I want the animation to stop, but the animation still continues to loop after 3 seconds. Here is the script --
local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://4594895034" local controller = game.Workspace.Martin.Zombie -- path to Humanoid/AnimationController controller:LoadAnimation(anim):Play() wait(3) anim:Stop()
The "anim:Stop()" part just doesn't work. The script is located in Workspace, and holds the animations that I want to use for the NPC.
You have to set a variable reference to the animation that has loaded which controls playing and stopping the animation, not the animation instance.
local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://4594895034" local controller = game.Workspace.Martin.Zombie -- path to Humanoid/AnimationController local Animation = controller:LoadAnimation(anim) Animation:Play() wait(3) Animation:Stop()