I have a quick question.
How would I install an animation override script into my game, basically when you press specific buttons, Example WASD? and when you press each button an animation plays but when you press a button the instantly press the other it stops the previous animation.
local animator = if Humanoid then Humanoid:FindFirstChildOfClass("Animator") else nil;
if animator then
local animTracks = animator:GetPlayingAnimationTracks()
for i,track in ipairs(animTracks) do
if track.Name == "NameOfAnimYouWantToStop" then
track:Stop(0);
end
end
if not animationTrackToPlay.IsPlaying then
-- Play the new animation if it is not playing
animationTrackToPlay:Play();
end
end
Why is the track being played in a loop? you have a task.wait() but no duration so this will continue on the next step i.e almost continuously it will be calling animation:Play().
There is also no animation:Stop() either, so they may be getting cued or the priority is getting mangled.
I am holding the keys in the first part of the video. but when I’m just pressing you can see the other animation will not play and override the previous
no no no, it overrides the current animation and plays the next one. It doesn’t wait until it stops, It completely stops the current one if you press another key that plays an animation