Hey guys, I think that I found a workaround for the problem. However, this still relies on the Humanoid.
How does it differs from MoveTo?
Good question. Instead, of using the function Humanoid:MoveTo
, I set the WalkToPart
and WalkToPoint
property in the script itself.
Basically, my idea consists to look goals as if they were directions. First, I tried to set the WalkToPart property to the PrimaryPart of the non-player characters and I would find the direction in which they had to go for reaching the point by doing the following :
local Direction = (Points[i].Position - Model.PrimaryPart.Position).unit*Model.Humanoid.WalkSpeed
I quickly noticed that this was wrong. In fact, the npc would just turn around himself. My solution to solve this first issue consists in creating part that always correspond to the position of the PrimaryPart of the said model. This part is going to be the WalkToPart property of the Humanoid. This is what it looks like when the part isn’t transparent :

Yes, there is a non-player character inside of that box.
Keep in mind that this box is always standing on the non-player character, that has been done in a while
loop. Also keep in mind that this box will always correspond to the player’s position, not its rotation, so I used .Position
and not .CFrame
because I don’t want the box to represent any sort of orientation since we’re going to use it in order to determinate the direction in which the player has to go in order to reach the point. I’m going to call this part the referencePart
for the sake of the simplicity and let’s just give it a smaller size such as Vector3.new(0.05,0.05,0.05)
. You can also make it transparent like I did.
Now I’ve covered the WalkToPart
, The only thing left is the WalkToPoint
property, but that’s quite easy to deal with. In fact, it just corresponds to the line of code I’ve posted up there except that there’s a little change :
local Direction = (Points[i].Position - referencePart.Position).unit*Model.Humanoid.WalkSpeed
The rest consists in doing a simple calculation, the time required in order to reach the part.
local RequiredTime = (Points[i].Position - referencePart.Position).magnitude/Humanoid.WalkSpeed
In addition to that, until the RequiredTime
hasn’t been reached, I constantly set the non-player character’s humanoid WalkToPoint
property to the current direction it has to take in order to reach the goal and finally, I added a check in order to see if the distance between the goal and the npc is higher than it was at the start. If it’s the case, I just find another path with PathfindingService
etc, etc.
That might not be helpful, but here’s some portion of the script that mainly explains my idea behind that. It’s a bit messy, I’m sorry, but it might do it. Note that the referencePart
is named ghostPart
.
for i = 2,#points do
if loopAgain == true and private_field.mentalState == "normal" then
local initial_mag = (points[i].Position - model.PrimaryPart.Position).magnitude
local timeRequired = initial_mag/private_field.humanoid.WalkSpeed
local inital_t = tick()
local keepWalking = true
private_field.humanoid.WalkToPart = ghostPart
local direction = (points[i].Position - ghostPart.Position).unit*private_field.humanoid.WalkSpeed
private_field.humanoid.WalkToPoint = direction
pointPosition = points[i].Position
spawn(function()
while keepWalking == true do
direction = (points[i].Position - ghostPart.Position).unit*private_field.humanoid.WalkSpeed
private_field.humanoid.WalkToPoint = direction
wait(.5)
end
end)
wait(timeRequired)
keepWalking = false
if (points[i].Position - model.PrimaryPart.Position).magnitude >= initial_mag then
loopAgain = true
break
end
end
end
If you have any questions, feel free to post them I guess?