Event runs on server but not client with keyboard input

Hello, I’m making a basic FPS and I’m having issues with reloading the weapon on both the client and server sides. Right now, I have a blueprint for the weapon which is called when the ammo in the magazine hits zero and plays a reload animation. This works fine on both client and server and plays the animation when the magazine runs out.

The problem is that I wanted to make it so the player can press R to reload and it does the same thing as the reload event mentioned above. However, this only works on the server side. I placed a print string to debug and I narrowed it down to the client not being able to get into the reload event when R is pressed. Why would this be happening? and why would the client side work when the ammo runs out but not when I press R? Thank you for any help!

Note: Attached are the events involved in reloading

Hi, directly inside the Reload event you use SwitchHasAuthority, and since I would assume that that actor was spawned on the server and is replicated, the server has Authority. So the client will get dropped there. To solve your problem, you can use a RunOnServer event directly after the InputAction Reload and call the Reload event of the weapon there. So client requesting server to do the reload.

For responsivness though I guess I would build the logic so that the client directly plays the montage locally. Otherwise after the key input you would have a delay since the RunOnServer event (which will be send immediately after getting called on the client) needs to get to the server and then the repnotify (which will not be send immediately but sometime) needs to get back to the client.

Thanks for the reply! Thats kind of how my shooting and damage system is set up and that makes a lot of sense. I feel like I’m missing something really basic or maybe this is the same thing I have above just written differently, with what I have attached, I get:

On the server:
Server: On Server
Server: On Client

On the client:
Client 1: On Client

What am I missing here?

What did you expect to happen? =)

Input actions will fire locally. So if the server hits an input, its going to execute on the server, if a client hits an input its going to execute on the client. So if the server presses Reload, then the server will execute Test and from that then ClientTest printing “On Client” and after that ServerTest printing “On Server”.

If the client presses reload, it will execute Test and from that then ClientTest printing “On Client” and then if* and only if* this actor is owned by this client (by default it owns its player controller and controlled pawn), the server executes ServerTest printing “On Server”. If this actor is not owned by that client, ServerTest will do nothing. Also non reliable RPCs might get dropped due to network bandwidth.
[HR][/HR]
For things like the players weapon you can set the owner of that weapon to that client. But if you would need to change ownership during the game, then better shift the RunOnServer event to either the player controller or the controlled pawn instead.

Thank you for your help! I got it working after moving the client and sever events to the character blueprint instead of the weapon blueprint

HI,

I am having a similar issue and wondering if you can offer input? I just getting started with this stuff. Ironically, chrudimer offered some input but he appears to echo what I am already doing with the exception of when he says “For example, from the ‘F’ → RunOnServer RPC → Server” where F is my key press event but I am not sure how to wire up RunOnServer RPC → server ???

Here is my post…