Issues with Humanoid.MoveToFinished:Wait()

Hello, I am having a pretty strange issue with my movement code and the cause is the
“Humanoid.MoveToFinished:Wait()” function, I removed it and then it went straight too the last point

Here is my code
image

This is the issue:
https://gyazo.com/6aa08c6fb7318ed08cf2351421929bd7

1 Like

The NPC will slow down as it approaches each waypoint. It might be better to create your own custom MoveTo function that finishes when the NPC is within a certain threshold of the target. You can attempt to remove this “lagging” issue by instead walking towards a point that is in the same direction as your goal but further away, but only walking to where the actual point is.

image

Where NPC represents the NPC, P1, P2, P3 represent the Positions the NPC needs to get to and W1, W2, W3 are the points the NPC will try to walk to. You will direct the NPC towards W1, W2, and W3 but stop them at P1, P2, and P3 and tell them to move to the next waypoint. This way they dont slow down because they’re not close to the target they’re actually trying to get to.

To generate each W point we take our P point, subtract the NPC’s position, normalize it, then multiply it by a new distance that is longer than the actual. Where N is the n-thW”; WN = (NPC.Position - PN.Position).Unit * NewDistance

1 Like

It’s a network ownership issue where the npc keeps switching from the client/server. Set the npc’s network ownership to the server to fix it:

function setNetworkOwner(character)
    for _, desc in pairs(character:GetDescendants())do
        if desc:IsA("BasePart")then
            desc:SetNetworkOwner(nil)
        end
    end
end

 setNetworkOwner(NPC GOES HERE)
9 Likes