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

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

Asked by 5 years ago

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?

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. TheOnlySmarts 233 — 5y
0
no.. Gey4Jesus69 2705 — 5y
1
this is why we need to be able to downvote comments DinozCreates 1070 — 5y
0
true Gey4Jesus69 2705 — 5y
1
Please accept gioni's answer, it is the correct answer. SteamG00B 1633 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

Ad

Answer this question