I'm making a chatroom where clients can send each other messages, but sometimes the client wouldn't receive the message.

My scene tree for the chatroom

My script

Can someone help me resolve this bug? If you need more information, please let me know.

In the first gif, I think the reason why the player can't see their own messages is because you're using the remote keyword instead of the remotesync keyword.

The difference between these two keywords is that remote only calls the function remotely, and not on the machine that called it. remotesync calls the function on both the machine that called it, but also calls it on all other connected players.

I'm not sure what's happening in the second gif. It seems like the function is only executing locally and not calling remotely. Is there any other code in your project? I would assume so since the script you're showing does not have any code to start the network.

Edit: Nevermind, I just noticed that you're also calling the code that player_to_chatroom() calls before making a remote player_to_chatroom() call. I'd still recommend using remotesync for neatness.

@Azedaxen said: In the first gif, I think the reason why the player can't see their own messages is because you're using the remote keyword instead of the remotesync keyword.

The difference between these two keywords is that remote only calls the function remotely, and not on the machine that called it. remotesync calls the function on both the machine that called it, but also calls it on all other connected players.

I'm not sure what's happening in the second gif. It seems like the function is only executing locally and not calling remotely. Is there any other code in your project? I would assume so since the script you're showing does not have any code to start the network.

Edit: Nevermind, I just noticed that you're also calling the code that player_to_chatroom() calls before making a remote player_to_chatroom() call. I'd still recommend using remotesync for neatness.

Using your advice, I set it so it does remote-sync instead of remote to call both locally and remotely. My issue still persist as shown in the gif where sometimes the client can see the message and sometimes they don't.

More info as to where my chat is used.

Some of the code as to how my multiplayer works

3 years later