RunOnServer event does not run on server but run on client instead!?

In my character’s construction script I had a call to a run on server event. It doesn’t run correctly so I put a breakpoint in the event and found that it was being run in the client!?

Here’s my blueprint

In ServerAcceptNewPlayer event I put an authority switch to check if it’s being run in server and it is not!
Bug?

Try use event BeginPlay instead of Construction script.
And there is described a pretty strange behavior, why do you need to make client to ask server do server-side work? Actually server here can use event BeginPlay instead of ServerAcceptNewPlayer, will be pretty much the same.

What’s wrong with client requesting server to do something? That’s what client server is for. Anyway, the reason I did that is for when character is created I need to send some info to the server and have it to replicate to all player’s PlayerState, replication can only done on server. Though, it’s not about my programming logic here it’s about why an event mark to be run on server instance has been run in a client instance which looks like it’s a buggy behaviour.

Possibly because of RPC lays inside Construction Script.
RPC calls allowed after actor been initialized, Construction Script executes before actor initializes.
About client call to server: can’t say much, I don’t know where it’s being called and is there any client info, but if there is any possible way to make some part of code fully autonomous, that it’s better to do it. The less you’ll have RPC call the more network stability you will get.

Hey edwardkoo,

To begin, I agree with HungryDoodles when it comes to using the construction script to have RPC calls. This is because if the Actor that is trying to call the RPC calls already exists in the world when the game starts, it wont work.

However, if you Spawn the Actor during run time, the RPC will work, as such:

Spawn a “TestingActor” from the Character Blueprint, using a Reliable Server event:

The Construction Script of the TestingActor:

The GameMode Event:

102904-469730_gamemodepng.png

And the result:

Now, if I simply place the TestingActor in the world and then press play. The RPC will not be called because the constructor was called before the game was running.

So, if you want to use the construction script to call RPC functions, make sure the object was created when the game is running.

Thank you for submitting a bug report, however at this time we believe that the issue you are describing is not actually a bug with the Unreal Engine, and so we are not able to take any further action on this. If you still believe this may be a bug, please provide steps for us to reproduce the issue, and we will continue our investigation.

Ok I got you mean. Thank you.