Need help on an event-based ability system

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?

4 Likes

animations on a character do replicate and should be played from the client you can read about it here https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation

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?

1 Like

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
humanoid.AnimationPlayed:Connect(function(animInstance)
    --do stuff like check what anim is being played
end)
-- 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
2 Likes

Thank you so much, I didn’t know you could do this. I need to get better at searching the documentation :smile:

1 Like

no problem glad to help :slight_smile: #30characters

2 Likes

Sorry for the necrobump but i’m having a similar issue and I don’t know how to solve it. How did you manage to check if a certain animation (that was loaded on the client) is playing, on the server?