I have this script which is supposed to make an AI move towards the player. This script works if you replace anything that says LeftHand with HumanoidRootPart. I had to change the script as there were multiple AI causing them to attack each other instead of the player. I deleted the left hand of the AI as it doesn't change the look of the AI and thought I could just have them track down the left hand since none of the AI have a left hand, however this doesn't work. I simply get a "Left hand is not a valid member of model" error. What can I do to fix this?
local larm = script.Parent:FindFirstChild("LeftHand")
local rarm = script.Parent:FindFirstChild("LeftHand")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 10000
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("LeftHand")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
return torso
end
while true do
wait(math.random(1,5))
local target = findNearestTorso(script.Parent.LeftHand.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
end

2 comments
Are the NPCs R15 or R6? On R6, the left hand is called "Left Arm," and on R15 it is as you stated, "LeftHand".
the npcs are R15