there used to be this old code that only works on r6 i think. i'm just going to reuse. the old one
here
01 | function findNearestTorso(pos) |
02 | local list = game.Workspace:children() |
10 | if (temp 2. className = = "Model" ) and (temp 2 ~ = script.Parent) then |
11 | temp = temp 2 :findFirstChild( "Torso" ) |
12 | human = temp 2 :findFirstChild( "Humanoid" ) |
13 | if (temp ~ = nil ) and (human ~ = nil ) and (human.Health > 0 ) then |
14 | if (temp.Position - pos).magnitude < dist then |
16 | dist = (temp.Position - pos).magnitude |
26 | local target = findNearestTorso(script.Parent.Torso.Position) |
28 | script.Parent.Humanoid:MoveTo(target.Position, target) |