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

Humanoid doesn't follow part?

I'm trying to make a part that will follow the mouse, this part works, however an NPC is meant to follow the part that follows the mouse. The only problem is that it goes to the original position of the part, instead of following it. (By the way theres a keybind that activates the movement, and it moves the part into the workspace so it's not longer in the replicated storage) Here's the script:

local GoHere = game.ReplicatedStorage.GoHere

while wait() do
	script.Parent.Humanoid:MoveTo(GoHere.Position)
end

1 comment

0

Odds are that the while loop runs before the event fires, so the Humanoid is literally going nowhere because the Part is not in the physical environment of the Workspace.

1 answer

You haven't given much surrounding context so I'm going to assume that you have cloned the part from ReplicatedStorage into Workspace and modifying its position from there.

If that's the case, the reason the humanoid is only moving to the original position of the part is because the target part in ReplicatedStorage and Workspace are different. Use the position property of the part in Workspace instead.

local GoHere = workspace.GoHere

while true do
	wait()
	script.Parent.Humanoid:MoveTo(GoHere.Position)
end

3 comments

0

Ah, yes.

0

The parent is set as the workspace.

0

Ok, that means that the while loop is running before the event fires.

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