Humanoid:MoveTo() not working in local script

I had some problem with my script

game.Workspace.Swordman.Humanoid:MoveTo(game.Workspace.TestPart.Position)

The npc move to the part in server script but when I use the exact same code in local script the npc doesn’t move at all.
My local script is in startergui and humanoidrootpart is unanchored.

I have also tried

local model = game.Workspace:WaitForChild("Swordman")
local humanoid = model:WaitForChild("Humanoid")
local part = game.Workspace:WaitForChild("TestPart")
model.Humanoid:MoveTo(part.Position)

but it doesn’t work too.
I have no idea how to fix this problem.

Try using a RemoteEvent and calling the MoveTo function from the server, that should work fine.

local scripts only work in the player character or places related to the player like, gui and tools i guess!
I mean the local script need to be inside of these places, they still can move your npc, just change the his place

Are there any errors? Also, you might want to consider the second parameter: the object.

Example: Humanoid:MoveTo(thing.Position,thing)

Does that help?

It work! but is there a way to move npc locally? It does move in server. here is my code rn.

-- in server script.
Action.OnServerEvent:Connect(function()
	game.Workspace.Swordman.Humanoid:MoveTo(game.Workspace.TestPart.Position)
end)
-- in local script.
Action:FireServer()

there is no error in output.

I tried your solution but it didn’t work.

I placed it in replicatedstorage and parented dummy to workspace via localscript and it work well!

Thank you!