Humanoid:MoveTo() not working for me

My code works perfectly fine in another game of mine, so I am not sure why it does not work now. I tried workspace.Robot.Humanoid:MoveTo(workspace.ChupaMiUwU.HumanoidRootPart.Position) in the command bar just to test and it did not move my robot. My code goes:

local function walkTo(target)
	targetReached = false;
	hum:MoveTo(target.Position,target);
	repeat wait() until (targetReached == true);
end;

local function destinationReached()
	targetReached = true;
end;

hum.MoveToFinished:Connect(destinationReached);

I have defined all my variables (again it works in my other game) but the robot just does not move. It throws no error and continues executing code afterwards, as if it did walk to the target (thread pauses for a while ‘simulating’ the movement of the humanoid but it does not actually move). Please let me know if you know how I can fix this, thank you! uwu

Using this line is going to stop your script until targetReached is equal to true.

repeat wait() until (targetReached == true);

Yep, that is what I wish for it to do. So that I do not have to estimate using wait() to run the next line of code.

Then I would suggest using

hum.MoveToFinished:Wait()

instead of using the repeat loop.

1 Like

Okay thank you! I will use that. However it does not solve my problem, the humanoid is still stuck, like an egg.

Is the humanoid’s model built correctly or is there anything weighing it down? Usually faulty ncps models can prevent them from moving.

Well I am no expert with NPCs, however I used the exact same model I built for my other game (directly copied) and it worked perfectly fine.

JUST tried something and I have no idea why it worked. I placed it in ServerStorage and cloned it into Workspace, that way the MoveTo() function works. Thank you both for your help! Still if you have a solution that does not require me to do this it would be of great help. ^-^