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

How to make a whole model moving like a single part with only script ?

Asked by 4 years ago

I know how to move a model in workspace but I dont know how to move it when I clone it from Relicapted Storage ( Plz help )

2 answers

Log in to vote
0
Answered by
Zeuxulaz 148
4 years ago

Make sure to set the model's primary part in the properties of the model. Then, in the script, reference your model and the position and use the :MoveTo() function like this:

local Model = game.ReplicatedStorage.MODELNAME:Clone() -- model name
local Position = Vector3.new(-- position)

Model:MoveTo(Position)

:MoveTo() moves the primary part to the given position and moves all the parts to the primary parts relative position.

Ad
Log in to vote
0
Answered by 4 years ago

So basically, when you clone an object an object it gives you the object if the clone function is in a variable, you also need to know how to use for loops, it's gonna be useful for models

local replicatedStorage = game:GetService("ReplicatedStorage")
local model = replicatedStorage.YourModel:Clone() -- if we now say "model" that means we are referring to the clones model

model.Parent = workspace

for _,v in pairs(model:GetChildren()) do
     if v:IsA("BasePart") then -- if one of the child is a part then
          v.Position = Vector3.new(0,0,0) -- if it's a part, change the position
     end
end

Answer this question