So I’m trying to get a model humanoid from one place to another like a player would walk. I’m not sure how to start scripting at all ![]()
Your best bet would probably to create two invisible walls beside the path and set it so only the NPC can collide with the walls, then use Roblox’s path-finding system.
I’m assuming you at least know how to define variables.
Define the humanoid object:
--example script placed under npc model
local npc = script.Parent
local humanoid = npc.Humanoid
Then, use the :MoveTo() method to make the npc walk. You do need to provide a position within the parentheses so the npc knows where to walk to.
humanoid:MoveTo(whereveryourpositionis)
If you want to use a part as kind of a waypoint, then you would define the part and use it’s position in the parentheses.
local target = workspace.targetpartorwhatever --workspace is where physical parts are
humanoid:MoveTo(target.Position)
Or, you could manually input a position with Vector3.new(). A bit more complex, as it requires a X, Y, and Z input.
--Example
local moveposition = Vector3.new(10, 30, 26)
humanoid:MoveTo(moveposition)
If you want the npc to then teleport after it walks to a point, then you would use MoveToFinished and the :PivotTo() method on the npc. PivotTo causes the npc to teleport to a set CFrame. Cframes are different than positions, so PivotTo will not accept positions. If you still input a position, then the script will error. If you REALLY want to use a position, then you’d use CFrame.new() to convert it.
--here is an example of converting a position to CFrame
local position = target.Position
local cframething = CFrame.new(position)
I’d rather just use part.CFrame as it is easier.
MoveToFinished is a script event that fires whenever a certain humanoid stops walking. Script events need to be connected to a function to do anything.
humanoid.MoveToFinished:Connect(function()
--any code in this part will run when the npc is done walking
end)
Within this function, you would have the teleport thing.
humanoid.MoveToFinished:Connect(function()
local cframeposition = target.CFrame
npc:PivotTo(cframeposition)
end)
If you want the npc to wait a little bit before teleporting, then you would add task.wait() before PivotTo. Within the parentheses, you would put how long, in seconds, you want the npc to wait.
humanoid.MoveToFinished:Connect(function()
local cframeposition = target.CFrame
task.wait(5) --waits 5 seconds
npc:PivotTo(cframeposition)
end)
If you have something like a intro menu where the user presses a button to start the game then you need to use things like remote events. I can help with those if you are using a start menu. Also, this is one of my first devforum posts so it might not be the best.

