Game State variable not changing for client when he joins the game?

I made a variable inside my game state called ‘kill count’ and set it to 0. To test it in multiplayer I’m playing in editor with 2 players. I’m hosting a session and a client joins it. When the host or the client kills an enemy the variable ‘kill count’ is incremented and both players see the correct value. I host a session and kill an enemy, the variable is incremented and is equal to 1. After this, a client joins the game but he stills sees the default value 0. What I’m doing wrong?
Blueprint:


inside the enemy BP I check if health is <= 0, if yes enter a switch has authority. On the authority node execute ‘Dies Multicast’ and updates variables. On the remote node execute ‘Kill’ that is inside the first person character blueprint. This event calls ‘Dies multicast’.

Do not use multicast to update variables.
Replicated calls are one-off events, they are not kept endlessly for clients who join later. If an event triggers and a player joins later, he will never see that event, so his variable won’t be updated.
Use a replicated variable instead. Just update its value on server (authority) side, and it will automatically replicate to all clients. Clients who join later will receive the variable’s latest value.

1 Like

thanks for the reply, I will be trying that

I did more tests and: I host the game and kill an enemy, the variable is updated from 0 to 1. The 2nd player joins the game and the variable value displayed on screen is the default value 0 and not 1. However, when another enemy is killed (by any player) the variable value displayed in both screens is 2 (the correct value). So it seems that the client knows the correct value, but only after accessing it. (?) Not sure what is happening.

Then it’s probably an issue with how you are updating the value displayed on screen