Can't make humanoid:MoveTo() work

I have been trying to make an AI for a while now, however it appears that I can’t make use of humanoid:MoveTo(). First I suspected I wasn’t able to create any waypoints but I deducted that it wasn’t the case and wasn’t a factor to this bug. I thought I had used something wrong so I looked up other people’s approach at AI but none of those worked for me for some weird reason.

I have been inserting a script directly inside a dummy created by the animation editor (by ROBLOX).

I am aware that there has been posts made similarly but none of them seemed to solve this case.

Code:

--//Services\\--
local runService = game:GetService("RunService")

--//Variables\\--
local character = script.Parent
local root = character:WaitForChild('HumanoidRootPart')
local humanoid = character:WaitForChild('Humanoid')
local part = workspace.Part

local path = game:GetService("PathfindingService"):CreatePath({AgentHeight = 5, AgentRadius = 2, AgentCanJump = false})
local newPath = path:ComputeAsync(root.Position, workspace.Part.Position)
local wayPoints = path:GetWaypoints()
if path.Status == Enum.PathStatus.Success then 

for _, v in pairs(wayPoints) do
	local part = Instance.new("Part", workspace)
	part.Anchored = true
	part.Size = Vector3.new(1,1,1)
	part.Position = v.Position
	part.CanCollide = false
	
	humanoid:MoveTo(v.Position)
	humanoid.MoveToFinished:Wait()
	
	if v.Action == Enum.PathWaypointAction.Jump then
		humanoid.Jump = true
	end
	if (wayPoints[#wayPoints].Position - workspace.Part.Position).magnitude > 15 then
		break
	end

end
end
2 Likes

Can you show the snippet of your code where you’ve used this?

1 Like

So, i tested this myself by putting this script in a normal script in the work space inside of a Npc and everything worked!, the only reason i think the Humanoid couldn’t move is if the HumanoidRootPart or any other joint part of the of the Npc is Anchored.

2 Likes

I once was having trouble with the Humanoid MoveTo stuff here is what I did to fix it:

Basically it keeps on attempting to walk until it reaches the waypoint it is trying to go to

repeat
	script.Parent.Humanoid:MoveTo(game.Workspace.WrestlingGame.WalkUp.SpawnerEnd.Position)
	wait(.5)
until (script.Parent.LowerTorso.Position - game.Workspace.WrestlingGame.WalkUp.SpawnerEnd.Position).magnitude <= 4

*Use this instead of the MoveToFinished

1 Like

Use your script locally and see if that helps, It can 'make ’ it work.Try it