Unable to Move NPC

Hey Developers!
I am currently making a story game, it is a collabration with @EconomicCrash47.
I am attempting to move the NPC, but I am getting this error:

WeridError

I have never seen it before, and I cannot understand what is happening.
Here is my script:

function MoveNpc(Location, NPCName)
	local NPC = game.Workspace[NPCName]
	NPC.Humanoid:MoveTo(Location.CFrame)
	NPC.Humanoid.MoveToFinished:Wait()
end

MoveNpc('Teacher', NPCPoints.Point1)

Any help is appreciated!

1 Like

The MoveTo method expects a Vector3 position, not a CFrame. So you want NPC.Humanoid:MoveTo(Location.Position) or NPC.Humanoid:MoveTo(Location.CFrame.Position) instead.

1 Like
function MoveNpc(Location, NPCName)
	local NPC = game.Workspace[NPCName]
	NPC.Humanoid:MoveTo(Location.CFrame.p)
	NPC.Humanoid.MoveToFinished:Wait()
end

MoveNpc('Teacher', NPCPoints.Point1)```

function MoveNPC(NPCName, Location)
local NPC = game.Workspace[NPCName]
NPC.Humanoid:MoveTo(Location.Position)
NPC.Humanoid.MoveToFinished:Wait()
end