Variable Replication not working

Hi guys,

i have a problem with variable replication with which i need some help.
I have an enemy actor who has a “health” variable which is set to replicated. I have a “hit damage” variable wich is also replicated and has a default value of 50.
So when i fire my weapon within the animation blueprint the event “GiveRangeDamage” is called within the enemy actor as seen in the screenshot. This is a multicast event which substracts 50 health points from my “health” variable.
My Tick event within the enemy actor always fires the “KillThisEnemy” event, which is also a multicast event. So when the enemy actor has a health value of 0 or below, the Kill functionality should trigger.
Now here comes the problem: The KillFunctionality triggers only on the client and not on the server side. So the enemy gets always killed on the client side but the server is still seeing the enemy acting like he hasn’t been killed.
Any solution for that problem, or do i do anything wrong with the blueprint scripting?

Thx for the help.

Replication only works from the server to the client, not the other way around. That means that enemies taking damage and being killed need to take place on the server. Seeing how health is a replicated variable, whenever an enemy’s health changes on the server, the value will then be also updated on all clients.

I think you need to change GiveRangeDamage to “Executes on Server”. You can also move the check for whether an enemy was killed right after the Set Health node (or move both into a separate ChangeHealth method), so you don’t need to query it for all enemies in the Tick method which is needlessly inefficient.

Thx for the help i figured that out. I changed the Multicast to RunOnServer as you said. But the main problem was that somehow i couldn’t call the RunOnServer event from my anim blueprint. i first had to call an evnet in my mycharacter blueprint which then called the RunOnServer event on my actor. That fixed the problem.