Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my NPC is not moving when I use MoveTo function?

His name is Tim and he is a model.

while true do
pos = game.Workspace.Part.Position
game.Workspace.Tim.Humanoid:MoveTo(pos)
wait(1)
end

1 answer

You forgot the local. When you put a variable and don't put local in front of it the game searches for a keyword that matches the word and if there isn't one, It does nothing.

while true do
local pos = game.Workspace.Part.Position
local Tim = game.Workspace.Tim
Tim.Humanoid:MoveTo(pos)
wait(1)
end

****If this answered your Question please press accept answer. :D

3 comments

0

The original code is not wrong since I successfully tested on Toolbox's NPC, but the NPC that I made can't move for some reason.

0

-1. Variables without the local keyword are global variables, not "keywords". Although they should be avoided, global variables can still be used to perform calculations. Plus, that does not solve the problem.

0

-1. General agreement with Link150

This discussion is preserved as it was. New answers, comments, and votes are closed.