Attack NPC attacking from far distances

I’m working on an attack NPC, and its attacking even when im not near it. I suspect this is due to Client/Server behavior, but does anyone know a fix?


image

image

((Would this be causing it??)

image

1 Like

Your attack magnitude is anything greater than 8 studs, so he is attacking you within the 8 stud distance. Try changing to greater than 2 and see if helps.

I cant show you in your code because it isnt formatted properly.

That is the distance that the NPC will detect players

Correct and it follows with else… so if less than 8 it deals damage.

Alright. If this is the root problem I will instead split the detecting and attacking.

Edit- Thanks! It worked

1 Like