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

I'm having a hard time moving a model, how do you do so?

i'm uh,, confused on how models have no position property,, and i dont know how to make a model move as a whole. like,

i'm trying to make this model move until it stops on a specific position. how do i do that if a model has no position property? is there a function for it?

5 comments

0

model:GetChildren().Position = Vector3.new(position) . This should work, Models are basically Folders for the Parts inside of the Model. Make sure that there is only 1 Part inside the Model, but the other ones inside that Part. This won't change anything other than keeping only one part instead of multiple inside the Model.

0

no..

1

this is why we need to be able to downvote comments

0

true

1

Please accept gioni's answer, it is the correct answer.

1 answer

✓ Accepted answer

To simply move a model, you can use the :SetPrimaryPartCFrame() method like so:

local model = workspace.Model
model:SetPrimaryPartCFrame(CFrame.new(0,0,0))

If you have a model with a humanoid in it (such as an NPC), you can use the :MoveTo() method. Please note that this method exists in models and humanoids, but when called upon a humanoid, it will cause the character to walk to the given point.

local npc = workspace.NPC
npc.Humanoid:MoveTo(Vector3.new(0,0,0))

Additionally, this method can be paired with the MoveToFinished event to detect when the character has reached their destination.

local npc = workspace.NPC
npc.Humanoid:MoveTo(Vector3.new(0,0,0))

npc.Humanoid.MoveToFinished:Connect(function(reached)
  print("Destination Reached!")
end)

The reached parameter returns true if the goal is reached within 8 seconds. Otherwise, it returns false.

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