Gameplay Ability on Client Crashes 100% - Running with Authority so ... is that not server?

The error is not very helpful:
image

The crash actually occurs on the first line but it does not matter what I do here, if I use K2_HasAuthority it will also crash.

image

image

This is called on an OnOverlap method from another object:
image

This one is painful. It works fine on server. From a listen server configuration the server character can get hit just fine. Client will crash it.

From a client configuration it always crashes. From my perspective, this CauseDamage ONLY gets called from the other object if it has authority (being on the server). So… what gives here? What magic am I missing?

EDIT:
After further investigation, HasAuthority() does not mean “on the server”. That is something that a lot of tutorials need to better explain because I hear a lot “we are going to call HasAuthority because only the server should be doing this”. In this case because the CLIENT MACHINE spawned the player character on the client side, then that client machine has authority even though its client-side.

A couple of tweaks which have fixed me on the Listen-Server side of things is to either make the CauseDamage an RPC call using UFUNCTION(Server, Reliable) OR by stating in CauseDamage_implementation:

if (TargetActor->GetLocalRole() == ROLE_Authority) // do stuff

Both of these resolve the crash.

Listen Server now works as expected but nothing at all happens if I’m using the client testing (its as if there is no server running). The enemy wails on the character and nothing happens.

Putting debug lines in I can see that indeed in the client only test version that the damage function now never gets called but it gets called in standalone or listen-server.