How to get nearest part from two with script

Soo i’m wan’t to make Enemy that follows nearest player, but the npc following a random from 2 targets, and i need to get the nearest distance.
i’ve trying to do math.min but it doesn’t worked

2 Likes

have you tried .Magnitude to get the nearest player?

(npc.Position - Player.Position).Magnitude

ok, i’ve made this , but anyway thank for help