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

MoveTo does't work properly?

Asked by 8 years ago

I'm trying to get an NPC to move to a random block inside a model. Here's the code:

local base = game.Workspace.Base

target = base:FindFirstChild("building")
script.Parent.Humanoid:MoveTo(Vector3.new(target.Position))

The NPC, instead of moving to one of the blocks, moves to the center of the baseplate instead. Any Idea why?

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

You're calling Vector3.new on an object that is already a Vector3. Doing this resets it to 0,0,0.

script.Parent.Humanoid:MoveTo(target.Position)
0
this is a good answer :) ConnorXV 5 — 8y
0
Ohhhh, Thanks!! ZeMeNbUiLdEr 104 — 8y
Ad

Answer this question