Run on server is never called, but server works fine

Hello.

I have an issue with replicating. I’ve created an actor with some simple mesh. I want to destroy it when a player interacts with it. this is my code.

The server destroys the actor just fine and it’s removed on the client-side aswell. But when the client interacts with the actor, nothing… The DestroyServer never gets called. I’ve checked every checkbox with the word “Replicate” on it. I’m all out of ideas. :frowning:

I’ve red something about some ownership and stuff but I havnt been able to change the owner, or I’m doing it wrong.

The mesh is not spawned it’s placed in the world (drag and drop) if this is at any help.

/Tobias

Hi, the only client that can call a “RunOnServer” RPC is the client that owns the actor.

Generally speaking in such a case you should view the client as monitor plus keyboard but do all the relevant logic on the server only. So the client never interacts with actors that are set to replicate, but where you handle the input of the client you directly use a “RunOnServer” RPC and let the server do all the logic/interaction.

So if you have an actor that the client owns like his weapon, then its no problem to let the client call RPCs there (cause you don’t want any other client to call events on that weapon). But if its an actor that every client needs to be able to interact with, then handle this on the server only.

I ended up rewriting large chunks of my project. I have googled a lot on how replicates work and it seems I got it all wrong. Thanks.