I’m trying to make a system for abilities in a RPG game. For example, one ability makes you lunge forward, dealing damage to enemies in your path. Currently, the system operates through signals attached to animations: each ability has a corresponding animation, with signals such as “ActivateMeleeDamage” or “PlayFX” that dictate the timing of events for the ability.
A major drawback of a system like this is that AnimationTracks are not replicated across the client-server boundary. That is, I don’t think it’s possible to obtain two references to an AnimationTrack (one on the server and one on the client).
Currently, I play animations entirely on the server. This method is straightforward: the client fires a request to cast an ability, and the server handles everything else, including playing the animation and listening to signals to trigger events. This is the current way I do it, but I am really concerned about the delay. Ideally the animation should be played immediately on the client to feel responsive.
So I thought another way to do things is to play the animation on the client, then fire RemoteEvents on every signal. This method would be more responsive, but introduces the problem of security. How would I go about checking if the events were fired legitimately and at the right times? An exploiter could fire these events arbitrarily at random times. In order to verify the events were triggered legitimately, the server would need to know the timing of the animation signals as well. I thought about creating a dummy humanoid for each player and loading the ability animation on each ability cast solely for the purpose of verifying the timing of events, but this feels very hacky. Another option would be to hard-code the timing of these events somewhere, but this makes things hard to manage.
I realize this is a long post, but I would really appreciate any support. How would you guys approach making a system like this?
Thanks, but that page does not detail how to get a reference to the animation from the server. I have already tried to pass AnimationTracks through RemoteEvents, they just show up as ‘nil’ across the boundary. Is there another way to get a reference to the AnimationTrack?
you can just use the animation played event on the server to check when a particular animation is being played like this
local humanoid = -- put humanoid here
--do stuff like check what anim is being played
-- so you would animate on the client and do the other things to replicate on the server
-- to do this for all characters you would just use a for loop to iterate over all the players and then get the characters from the humanoid and then just attach the function to the player added event