Array not updating with client information

Working on a BP that allows the players to add names to the player character. Once the name is entered, I want it to be added to an array to have a list of names that have been used. For some reason I am only able to add the character name from the server, and not the client. I have tried everything that I know when it comes to replication, but I am also new at it. The information is stored in an Actor Component.

Any advice will help. Please see the attached picture.

Hi!

As far as I know, you cannot just change replicated variable on client and wait for it to update on server. I think, you need to explicitly ask server to add new name into an array from client by using an RPC.
If array of names is set to be replicated (which it should be), then changes which will occur on server will be replicated on clients, without any need to call a multicast event to update it.

Create custom event that will be running on server, in which you will add new name into an array

And then just call that event from client.

Please, try and tell, if it helps.

Everything you say is correct. But your “Names” variable is missing a white ball. (It is not replicated)

1 Like

Same thing. The array doesn’t update with the client information.


Do you BP_NameServer actor is set to replicate too?

Yes.

The event “Client: Update Name List” is not necessary.
In fact… you only must modify replicated variables from the server.

Maybe you need to use the “HasAuthority” node to execute your “Server: Update Name List” event

I have tried everything I know and followed every advice that has been provide. For something reason, nothing works on the client, but it does on the server.

That is a Widget right? it is in the HUD?
1 - Put that event in the PlayerController code
2 - Call the even form the Widget unsing the controller

It is a widget and currently set up in the character on event begging play. it will check is the player has a name. I have attached a screenshot of my current setup.

The Widget does not exist in the server (When you are not the host)… you need to use the controller to comunicate with the server

So, use the same upset but call it from the controller?

that is!!

current setup. I’m about to try it.



You must put this in the controller

The rest you can leave in the widget if you want

2 Likes

Take a look of this:

1 Like

Thank you very it worked.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.