Hi, my game has 2 players, a host and a client. When either player runs out of ammo, I am trying to give the other player a free headshot. When the host runs out of ammo, the client gains the lock on, but when the client runs out of ammo, nothing happens. I checked using a print text that updates whenever either player shoots and the server cannot see the clients ammo count change when they shoot, it stays at the default (6) while the client can detect the hosts ammo count changing. Is there any way that I can let the host see the clients variable changing live?
You need to make sure the ammo count is being updated by the server when you fire, so it replicates the correct value from server to client. Changes a client makes (without using server) to a replicated variable do not reflect on the replicated variable.
considering both are using the same blueprint, how would the server update it without it decreasing BOTH players ammo? I tried doing something like this, but it still didn’t work.
Get rid of the owning client RPC and put the decrement in the server RPC. It will only fire on the instance that calls it, not all instances of the blueprint.
thank you so much, that worked, but now the client has 7 ammo for some reason, the ammo value still starts at 6, but now the client only stops firing at -1 ammo
I can not see that whole line in the screenshot, but I’d assume some of that is not being done in the server. The condition check and bHasAmmo should be done in the server as well for example.
you’re a hero, it’s all working.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.