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