How to play animationTracks from other scripts?

What do you want to achieve: I have been working on a combat system based on the one from the culling, so in the game theres some mechanics such as light punching, charge punching, blocking, and shoving, Shoving will stun you if you were blocking so the issue here is, When you get shoved the local script runs the whole hitbox code and if it detects someone (Yes I use hitscan for this) it will go fire a remote event and stun that person from the server script

  1. *What is the issue?: Heres where the issue come, when you get shoved you need his weapon idle animation to be stopped and then you play his stun animation and then you go back to playing his idle animation if his tool is still equipped, But the problem is you cant really play a “victim’s” Animation tracks from a different script or stop them.

  2. **What solutions have you tried so far?: I tried learning about bindable events to try and fire a stun function from the attacker’s script to the victim’s script so it plays the victim’s animation tracks and this way I can play them and stop them but Iv’e heard bindable events can only be fired once at a time and I don’t know how well this might work and dont think it can even work due to the way ive designed my code.

So I would like if someone told me what would be the best way to go on about this, Maybe theres something I haven’t found out about yet on the dev hub that is legit what I need but I couldnt find anything, So again if someone told me a way I could do this it would be appreciated

If pictures are needed ill provide them.

When you fire the remote event to the server to deal damage, you could send a 2nd parameter (or a 2nd remote event) detailing the name of the animation you want the other player to do. Then on the server you can send a remote event to the other player, and they can receive it and simply play the animation as requested.

1 Like

Wait gnome code is that really you?, Anyways so i have 2 remotes, so the way you tell me to do this is, I have all remotes, local scripts and server script needed inside my tool, (Will probably eventually find a way to move all this mess to a single remote on replicated storage, or even a module) so what I would do is first they press Q wich plays the shove animation on the client view models, Then it fires a remote event that plays the 3rd person shove animation from the server, Then the local script also fires a second remote event if someone is near (Aka the hitbox) then the server will proceed to check if the person who you aimed at is blocking and if he is he will shove, (The script is located inside the tool btw on not on server storage) then the server script proceeds to stun the victim and load an animation track, But what you want me to do is from the remote i fire to the server also fire some kind of script inside the victim?

lIll send a picture of the way i organized my framework
image

image

1 Like

You could write the animation functions in a module script and require that module from local scripts. I think using bool values are great, since it doesn’t require remote events to make those changes from the client-side. Whenever the character takes damage and a status is changed, those animations can be connected and that same module script will do those animations for you.

Could you link some good resources to modules? Ive heard of them but I still dont understand what to use them for, Are they like just scripts that have functions you can call from others and pass arguments?

oh yeah and one more thing, If this module is on the server script storage, Then wouldnt that mean im always loading new animation tracks to everyone who uses it instead of just loading them and then playing them for everyone since anyone can call the functions

It took me a while to learn the proper usage of module scripts, but DataStore2 and a variety of Admin command scripts like HD Admin or Adonis are great examples, since they’re already clean frameworks.

For the client to use module scripts, it would have to be in a directory where the client can see, such as the ReplicatedStorage or PlayerScripts. Other than that, if you’re using module scripts solely for server-sided, I’d store them in ServerStorage.

Im kinda gonna have a headache porting my engine to a script or more on server storage and then make them connect to a module script, What would be the best way to do this?, Set up all my remotes on repplicated storage and have all my actions be done from server script storage scripts? wait how would that work, If i do that then why would I need the module at that point, Im confsued how should I arrange my stuff?

Your remotes will always be in a place where both the client and server can see, which is the ReplicatedStorage.

For client-sided scripts, such as animations and UI, you’d put the module scripts in the ReplicatedStorage because you want to allow the client to access those functions.

For server-sided scripts, such as an anti-cheat, you’d put the module scripts in ServerScripts or a place where the client can’t access.

Essentially, module scripts are just scripts that hold different functions or variables that can be used with any script, depending on where you store them.

One question! So I want my remote event to fire a module script on the server storage so the client cannot see or tamper with it in any way, So One question, Can a module script request something from a script and then have it send to it, For example, A player attack, It fire their attack remote and passes the damage calculated from the client (Yes I do the calculations from the client bc using the server uses way too much resources and delays inputs) and the victim if it hit any, Then the module script picks up the table sent by the client but it needs to play the anims, Heres the thing we cant load the anims from that script bc if someone calls it again its blind to other loaded anims or something so it will create a new track instead of stopping or playing the ones already playing, So could I just have my animations loaded on a tool’s server script and the animation tracks inside a dictionary table, So when the remote event gets fired it can just request the table from the script inside the tool where the anims are and have it sent to the module so it can play them or stop them from there?

I have changed the answer to a much clearer on if anyone has any doubts on this topic so they can find the solution.

It is recommended that you store your animation tracks inside a module script, I put it inside the player’s Character, Heree you can write on a table the animation tracks so you can require them from other scripts and stop them.

2 Likes

can you explain it more … isnt sending values to to a table inside of moudle script from a client script doesn’t change the server moudle so when i require that moudle on the server and get that table we dont get the new values sent to that table from the clients … that example applies for the animation tracks. my question is how to transfer the same animation track from ther server to a client and vice verca