Animation isn't playing

so i want to repeat an animation and stop when the player moves

somewhy the animation is not playing, i loaded it with animator:LoadAnimation and its not working and also not repeating
when im putting a print it prints only one time and then stops

here is this part of my code (if you need more of the code tell me)

local animator = humanoid:FindFirstChildOfClass("Animator")
				
				local animationTrack = animator:LoadAnimation(game.ReplicatedStorage.Animations.SwordAnimation)

				if animator then
					repeat
						if not animationTrack.IsPlaying then
							animationTrack:Play()
						end
					until humanoid:GetPropertyChangedSignal("MoveDirection")
				end

i dont know what i did wrong here, thanks for trying to help

Probably because the MoveDirection changes during your movement, meaning even if you yourself didn’t move your player, the MoveTo you probably had changed the MoveDirection. You can try it out yourself via printing the movedirection.

You’re gonna need to try something else out to detect movement from pressing/touching than cause the Humanoid’s MoveDirection changed. I’m not sure how though, all I know is that the MoveDirection is probably changing itself. Or else, maybe it’s cause you’re doing it incorrectly, try this maybe?

local animator = humanoid:FindFirstChildOfClass("Animator")
			
local loop = true		

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	loop = false
end)
	
local animationTrack = animator:LoadAnimation(game.ReplicatedStorage.Animations.SwordAnimation)

repeat
	animationTrack:Play()
    animationTrack.Stopped:Wait()
until not loop

i just back, i did the animation loop after i did
humanoid.MoveToFinished:wait()
so i dont htink thats the problem

Hmm, may still try out the code I’ve provided, it could’ve been how you were making the condition for the until

Why don’t you fork the Animate script and make the idle animation custom? That plays when the character doesn’t move

sorry i had to go, i tried the script that you send, its not playing the animation but if im printing there it works…

oh turns out that was just the animation, i tried getting another animation and it worked out, thanks anyways btw EmbatTheHybrid really cool

1 Like