Module Script Not Stopping animation

So my module script is not stopping my animation at all. It can play and stop sounds but for some reason its not stopping the animation. The animation is the players hand vibrating quickly for four frames, the priority is “Action 3” and it is set to looped in the editor.

  1. What do you want to achieve? Play the animation if a bool value is true and stop it if false on a module script.

  2. What is the issue? The module script is playing the animation but does not stop it. (The sounds are working fine)

  3. What solutions have you tried so far? I’ve looked for this issue and nothing came up, I’ve tried turning off “looped” because I thought that it would fix it for some reason :man_shrugging:

I have a local script which is firing a remote event to a server script. The Server script then calls a function from the module script inside of it. The animation plays, but wont stop. :arrow_down_small:

Module Script:

Here is the local script:


I have a feeling this is me just using module scripts wrong but hop fully I can learn from this first post.

Seeing it first hand it might be that you are using Humanoid:LoadAnimation which is depracated instead of Humanoid.Animator:LoadAnimation(), not sure though, I will test some things out and write a better responde in a while!

1 Like

I’ll try it but I just tried running the :Stop() 1 second after it plays and it worked! If I don’t find a solution to do it the way I want then I’ll resort to it being an attack sequence instead of an attack mode. --Edit I tried it but it didn’t work

1 Like

You need to re-edit the animation, and set the looped property to false in the animator, then publish and overwrite the old one. That should work.


Alright I’ll try but I’m pretty sure I already did… What do I do with the “looped” in the script?

1 Like

What if it’s because you’re playing the player’s animation through the server? The controlling of the animation seems to do better if you were to play/stop it from the client, from my experience. (I’ve had this similar issue before)

Just throwing a suggestion of what might be the problem, not saying it would fix it or anything.


Don’t do anything about it, don’t change the property. If that doesn’t work please say so!

1 Like

would that play the animation locally? (im new to working with animations)

The animation doesn’t loop now…

If the humanoid was made from the server and isn’t controlled by any player, then it would play locally for that specific player. Else, if it’s being played locally from a humanoid controlled by the player, it’d replicate to the server. It’s pretty weird how some things replicate and don’t when it comes to the player.

For example, you know the roblox’s built-in animation script for every player? It’s being played by a LocalScript.

1 Like

The local script I would use is in the character. Does that count as “Controlling the player”?

If you’re trying to play the animation from the player’s character, then yeah, it should count as controlling the player if I’m understanding you correctly. Plus, it is actually more preferred to play an animation (that’s for the player) from the client’s side. (don’t quote me, though)

1 Like

How do I locate the module if its in Server Script Service?

You wouldn’t be able to get the ModuleScript from the ServerScriptService on the client’s side, since anything stored in the server is hidden from the client. So, you’d either have to move it in ReplicatedStorage to have it be accessible for the client AND server, or you’d use a remote… Which may not be the most optimal solution.

Okay, I moved it under the local script and then called by the local script and its kind working, what’s happening is it stops but you have to press “t” (the toggle button) 3 times before it completely stops.

Oh wait I think that for it to stop I have to press T at the frame that the animation restarts the loop because its not 3 it takes a lot of attempts. THIS IS SO WIERD

Okay, I see the problem here fully now.

The problem would come from the ModuleScript function. :LoadAnimation() doesn’t find that same animation that you’ve created, but instead create an entirely new one for you to manipulate each time it’s called. The only reason the animation is stopping is that the animation isn’t looped.

I don’t want to change your code a lot, so I’ll just say what I’d do in this situation is either loop through the Animator’s currently playing tracks and find the track that has the same AnimationId as the SawHand Animation, or I have the function return the SawAnim and manipulate that on the client instead.

This is how I’d do the “looping through the animators current playing tracks” code:

-- ServerAbilities: ModuleScript
-- Code after the next two comments starts on Line 10 as an addition to the Abilities.SawHand function.

-- I'm going to assume you've already checked for the Animator for Humanoid. 
-- But, I'll put this here just incase:
local Animator = Humanoid:WaitForChild("Animator") -- if it's a custom character, maybe you'd want to place the Animator inside the humanoid.

local SawAnim

for _, track in Animator:GetPlayingAnimationTracks() :: { AnimationTrack } do
    local _Animation = track.Animation
    local _animId = _Animation.AnimationId

    if _animId == Animations.SawHand.AnimationId then
        SawHand = track

-- then the remaining lines of code gets put here...

And then, for the other option, I’d just have at the end of the Abilities.SawHand return that SawAnim and use that within the LocalScript.

-- ServerAbilities: ModuleScript
-- This one piece of code is the last line within the Abilities.SawHand function.

Abilities.SawHand = function(Character, play)
-- Everything is the same, except now we just return SawHand
    return SawHand

-- And we'd use that returned AnimationTrack for our LocalScript to manipulate the Animation from the client's side.

Wait the for loop replaces the “local StabAnim = Humanoid.Animator:LoadAnimation(Animations:FindFirstChild(“Stab”))”?

1 Like

Well, I guess you can say that.

How is your code looking like now before I say that it should replace that line?

How do I make the message I send automatically use Lua like you did?