MoveTo() and MoveToFinished not working, im stumped

  1. I want to click and get the mouse position, then on the mouse position a small part spawns in which another part called army moves to. The part is in a model called HumanoidRootPart and in the model as well is a Humanoid. The parts are also unanchored.

  2. What is the issue? The part called army is not moving whatsoever and stays still. The code completely runs through as normal but MoveToFinished doesnt reigster.

-- VARIABLES --

local player = game.Players.LocalPlayer
local marker = game.ReplicatedStorage:WaitForChild("GoTo")
local mouse = player:GetMouse()
local Army = game.Workspace.Army -- Make sure the character is in the Workspace

-- MAIN --

local function Pathfinding()
	
	local MarkerClone = marker:Clone()
	
	MarkerClone.Parent = game.Workspace
	print("Marker Cloned")
	
	MarkerClone.Position = mouse.Hit.Position
	print("Coordinates : ", MarkerClone.Position)

	Army:FindFirstChild("Humanoid"):MoveTo(MarkerClone.Position)
	print("Army Relocating...")
	
	Army.Humanoid.MoveToFinished:Connect(function()
		print("Army Relocated")
		MarkerClone:Destroy()
	end)
	
end
mouse.Button1Down:Connect(Pathfinding)

1 Like

Is there any errors? It’s probably because you can’t move a humanoid through a localscript.

1 Like

oh my god that might be it, let me try it out.

1 Like

As @melvinpetersen said, it won’t work if you try to move the humanoid through a Local Script.

(writing this message since I had the same issue a couple days ago) If it still doesn’t work after you switched to a Server Script, make sure the humanoid’s position is NOT updated before you call MoveTo() (as in, make sure the humanoid is static) and make sure the humanoid’s HumanoidRootPart is not anchored.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.