#Question:#

So I have:

local offset = 5
local module = {
	getTarget = function()
		-- that irrelevant stuff here
	end,
	
}

for _, NPC in pairs(workspace.NPC:GetChildren()) do
	local target = module.getTarget()
	NPC.Humanoid:MoveTo(NPC.PrimaryPart.Position, NPC.PrimaryPart)
end

return module

So what I'm trying to do is implement the offset variable into the MoveTo. I don't mean pos+Vector3.new(offset,0,0) either. What I'm looking for is a NPC to move to a target in the shortest distance possible.

I don't want to specify which axis the npc has to be away from but I want the NPC to move to a target but 5 studs away preferably the closest axis. Again I don't want to specify the axis but I'm just not sure how to implement this.

Thank you for any feedback.

2 comments

0

Couldn't you just MoveTo to the target, and wait until you're at a magnitude of 5 studs, then stop the humanoid?

0

@Activatted that wouldn't work since I'm using pathfinding which complicate things