Help with determining what type of remotefunction / event I need for combat script

I’m currently working on an input script for the client which handles all the user input including firing remotes when the user wants to use a tool, now I plan to animate on and client and have other actions the player can take, for this reason I need the server to be able to tell the client that an action is currently being performed i.e Client Fires Remote → Server makes the client swing their sword → Client is debounced so they cannot climb while swinging their sword.

What’s the best method to getting this information back to the client fast and reliably?

1 Like

It’s typically bad practice to have the server do something to the character.

I’m unaware of how much you know about Network Ownership, but a player is by default a Network Owner of their own character.

This means that, if you were to animate something on their client, it would replicate out to the server. This doesn’t go for all properties, but most visual properties, etc.

Doing anything that should be smooth, like animations, should be avoided on the server because network lag will cause it to be jittery, and it puts unnecessary stress on the network as well.

What I suggest doing, if the server doesn’t already replicate actions/animations from the client, is have the client fire a remote event, then the server, do any server-side calculations, disregarding VFX, animations etc. then fire to all clients, and then all clients do the required VFX.

But otherwise, you don’t really have to worry about the network or remote events, you can just do it on a local script if it’s reserved to the character.

Hey I appreciate the response but this was NOT what I was getting at, I apologise for not being clear. The current setup is as you described which is the Client Invokes a remote to attempt to use a tool → Server Checks and does calculations and then I’m unsure how to communicate to the client to have the client then perform said actions and apply the debounce etc. I was thinking since remotefunctions yield until they receive a response I could use one and have it wait for the server to check and respond before moving forward or perhaps something else. Really I’m just confused on how to effectively give the client values and signals from the server so that it can act on them and know whats happening.

Just to confirm, the way I would achieve this would be having the server just fire a remoteevent with the relevant information including to all clients to have them perform the required actions? i.e player1 uses swing, everyone animate that?

I could also use said remote to confirm that “swing1” was performed and to debounce for x amount of time

Is this for the purposes of anti-cheat? Because I’m not quite sure why you’d need to have this back-and-forth with the client and server over some sort of action.

Well since the server performs all the calculations, the input script ( localscript ) invokes the server saying basically I’d like to attack, if the server then goes ahead and says sure! and then performs the required calculations - I need the client to know that an attack is being performed so I can for instance debounce the input so you can’t run while swinging the sword. I’m just a little confused on how I’d get this to work since I’m fairly new to coding w/ animations and client sided things.

I wouldn’t worry about the animations, again as I explained that should sort itself out.

As far as getting an okay from the server, that can cause a delay in input, which isn’t ideal.

Me personally, I like to give the client free reign, with the server monitoring all it’s actions, doing sanity checks, performing anti-cheat calculations, and if it spots anything suspicious, can block future actions for a period of time, or out-right kick that client.

So I’d have the server still doing it’s thing in the background, but just keeping an eye on the client, opposed to doing everything for the client. So perform these things on the client if at all possible, and let it do it’s thing, while the server just double checks.

The client is typically much stronger, processing-power-wise, than the server, so it’s always good to try to keep it’s load light. Plus, lag for the server is lag for everyone.

Being invasive like that isn’t ideal.