Problem with stopping animation

Hello, i am trying to stop a walking animation after a npc has walked to a place, but i can’t make the animation stop.

I have tried to just type :Stop(), but that didn’t work. I then tried to read some stuff about animations, but i could not find a solution.
My last try was to type :Stop()
and then play a diffrent animation but that didn’t work.

Thanks for you answers in advance!

Here is my script:

local rep = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local part = game.Workspace.cammove.Part

local remote = rep:WaitForChild("run")
local runAnimation = game.Workspace.Davidsuperhero1076:WaitForChild("WalkAnim")
local WalkAnimationTrack = game.Workspace.Davidsuperhero1076.Humanoid:LoadAnimation(runAnimation)
print("AAAAAAAAAAA")
local function on()
	WalkAnimationTrack:Play()
	game.Workspace.Davidsuperhero1076.UpperTorso.Transparency = 1
	game.Workspace.Davidsuperhero1076.Humanoid:MoveTo(game.Workspace.move1.Position)
	game.Workspace.Davidsuperhero1076.Humanoid.MoveToFinished:Wait()
	game.Workspace.Davidsuperhero1076.LeftUpperArm.Transparency = 1
	game.Workspace.Davidsuperhero1076.RightUpperArm.Transparency = 1
	game.Workspace.walk.Value = 1
	wait(2)
	game.Workspace.Davidsuperhero1076.UpperTorso.Transparency = 0
	game.Workspace.Davidsuperhero1076.LeftUpperArm.Transparency = 0
	game.Workspace.Davidsuperhero1076.RightUpperArm.Transparency = 0
	
	game.Workspace.Davidsuperhero1076.Humanoid:MoveTo(game.Workspace.move2.Position)
	game.Workspace.Davidsuperhero1076.Humanoid.MoveToFinished:Wait()
	game.Workspace.Davidsuperhero1076.Humanoid:MoveTo(game.Workspace.move3.Position)
	game.Workspace.Davidsuperhero1076.Humanoid.MoveToFinished:Wait()
	game.Workspace.Davidsuperhero1076.Humanoid:MoveTo(game.Workspace.move4.Position)
	game.Workspace.Davidsuperhero1076.Humanoid.MoveToFinished:Wait()
	WalkAnimationTrack:Stop()
	print("a")

end
remote.OnServerEvent:Connect(on)

You’re playing idleAnimationTrack and then stopping WalkAnimationTrack, you’ve defined the wrong animations

Also I don’t see idleAnimationTrack defined anywhere

1 Like

Oh sorry, i copied some stuff from a diffrent script and then tried to change it so it made more sense in this post, so i did identify the right animation in the original script.

Yea that should work fine, And you don’t really need to do remote events for animations since animations replicate from client to server.

Sorry again, i didn’t explain it clearly. The script does not work and it was already defined correctly in the original script and the mistake was only in this post because i tried to change the text so it made more sense.