I am currently trying to make a game that includes Enemy NPCs.
I have a follow script on these NPCs but they are not targeting me, instead they are targeting each other when they spawn.
I know I need to change the name of NPCs Humanoids but Im really new to scripting and i cant seem to find where to change the name to.
( also I want to make different groups of NPCs so I need to know where to change the name, please dont just send me a fixed script )
here is the current follow script I have on the NPCs:
local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 100
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("Torso")
human = temp2:findFirstChild("NPC")
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
end
return torso
end
while true do
wait(0.1)
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
end

1 comment
he said attack players not eachother