Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Humanoid doesn't follow part?

Asked by 5 years ago
Edited 5 years ago

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
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. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
5 years ago
Edited 5 years ago

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.

```lua local GoHere = workspace.GoHere

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

0
Ah, yes. DeceptiveCaster 3761 — 5y
0
The parent is set as the workspace. CaptainAlien132 225 — 5y
0
Ok, that means that the while loop is running before the event fires. DeceptiveCaster 3761 — 5y
Ad

Answer this question