Pathfinding is broken

Hello, I would like to know what’s wrong with my Pathfinding robot.
Its a Humanoid body, with the robot on the head motored on it.
It should follow you, but instead it spins huge circles or glitches behind or infront of you.

local hrp = script.Parent.HumanoidRootPart


local function Follow()
    if not script.Parent.FindTarget.Aggressive.Value then
        local distance = 100000 
        local nearestPosition
        for _, player in ipairs(players:GetPlayers()) do
            local Owner = script.Parent.Drone.Owner
            local target = workspace[Owner.Value].PrimaryPart
            if target then
                local magnitude = (target.Position - hrp.Position).Magnitude
                if magnitude <= distance then
                    distance = magnitude
                    nearestPosition = target.Position

while true do

1 Like

You’re not setting what the NetworkOwner is. There should be the player object in the parameters

I know that, but having it in or out doesn’t fix it saddly

What is the structure of your robot? It could be a rigging problem

Tried a Human rig, same problem

You could try PathfindingService or instead of using a while loop, wait for when the player has moved, then call the follow function

I tried that. I basicly had issues with multiple pathfinding ways, no matter what i tried it would keep doing something else, like glitching, or spinning… Thank you for your help, but I don’t know what to do now, I basicly don’t even know why I asked, because I really tried EVERYTHING, well… If you don’t see any errors in this script, I don’t really know…

1 Like

I’ve had this problem too, and Roblox should make pathfinding much easier. I spent all day one day figuring this out and all I came too was that humanoid.MoveToFinished:Wait() makes it move, stop, move, stop, and setting the network owner was getting closer to the solution

I use/used both of these in my System, it did not work well. It might just be a roblox issue or something like that.