Stopping all animations

I’m working on an animation system where you can use commands to play different dances for your character. How do you stop an animation without having to have the animationtrack variable?
Code:

commands.bloodpop = function(sender)
	local anim = sender.Character.Humanoid:LoadAnimation(script.Pop)
	anim:Play()
end

commands.stop = function(sender)
	
end

Well i never coded before… But try using some If player says something Then
AnimationTrack:Play()

I can already play the track, just I don’t know how to stop the animation without the animation track variable.

Use the function Animator:GetPlayingAnimationTracks which returns an array with the currently playing AnimationTracks and then you can loop through the table and call AnimationTrack:Stop on each AnimationTrack

2 Likes

If @iBuzzes Idea dont work then use a command that stops the animation like:

if player typed a command then
AnimationTrack:Stop()
end

Is there a way to detect a player’s movement?

it doenst work sorry … i tried

1 Like

Where is the animator object? I don’t know where to reference it.

Nevermind. It is in the humanoid.

Check if property Humanoid.MoveDirection in magnitude is greater than 0

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")

task.spawn(function()
	while task.wait() do
		if Humanoid.MoveDirection.Magnitude > 0 then
			print("The player is moving")
		else
			print("The player is not moving")
		end
	end
end)

It worked, thank you so much. I couldn’t be more greatful.

1 Like