Why Isn't MoveTo Working

Hello devs, I’m not sure why MoveTo isn’t working as it’s not moving. Can you please provide some feedback on how to fix this? Thank you!

And, it’s a local script!

Script:

local Humanoid = script.Parent:FindFirstChild("Humanoid")
local player = game.Players.LocalPlayer

wait(2)

Humanoid:MoveTo(player.Character.HumanoidRootPart.CFrame)

Local Script in where? If its in workspace, change the location of the script since Local Scripts dont work in workspace…

2 Likes

You’ve given a CFrame as an argument. MoveTo takes a Vector3

2 Likes

its in the npc…

that has a Humanoid in it!

and sorry for the late respond!

oh, sorry i will try it thank you!

you are trying to make humanoid to move to it’s current location
try this code

local Humanoid = script.Parent:FindFirstChild("Humanoid")
local player = game.Players.LocalPlayer

wait(2)

Humanoid:MoveTo(player.Character.HumanoidRootPart.CFrame.Position + Vector3.new(10, 0, 0)

Use a normal Script instead. LocalScripts can only run in the player or the player’s character, not in anything else.

If you want the NPC to move to the player only on the player’s client, try using a LocalScript in the player itself instead through StarterPlayerCharacter to move the NPC.

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