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 )
✓ ANSWER ACCEPTED
How to make a whole model moving like a single part with only script ?
2 answers
✓ Accepted answer
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.
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
