Is there a way for server to command all connected clients

I’m trying to make a server command clients to do UI work.

so I got all connected client’s player controllers with GetAllActorsOfClass function ( already checked if those are not null controllers)

However, those clients controllers have null Widgets which i set in beginPlay()

so, whenever i try to modify that widget of clients, they break.

Please help me

Yes, server sides of controllers don’t have widget references, because widgets only exist on client sides.

So you can either create a Client function in your controller class and make each controller call its own client function, or create a NetMulticast function in the class where your server calls the functions.

Either way, you need to communicate to clients first, and let them work with their respective widgets later.

You have two ways of doing what you’re trying to achieve;

As said by Tuerer, you can make a NetMultiCast function that will get executed on all clients. You simply would have to call it from the server and implement inside of it what every client should do to itself (and ignore the function execution on the server if that’s what you’re looking for)

  UFUNCTION( NetMulticast )
  void MulticastRPCFunction();

For more information about RPCs (Remote Procedure Calls) you can check this very useful page on the official doc: RPCs | Unreal Engine Documentation


Alternatively, if it’s about notifying a state change to each client individually you can use a replicated variable on the controller that you can change server side, and then hook the appropriate UI effects to OnRep_YourVariable

  UPROPERTY( ReplicatedUsing = OnRep_YourVariable )
  YourVariableType YourVariable

More info about replication can be found here: Property Replication | Unreal Engine Documentation

And here: https://www.orfeasel.com/networking_intro_p1/