How do I change the position of a model?

  1. What do you want to achieve? Keep it simple and clear!

I want to make the model to change its position. I have already get the children inside of the model since there isn’t any position properties of a model. I also change the children position.

  1. What is the issue? Include screenshots / videos if possible!

it is not cloning nor is it outputting any errors…

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried looking for solutions on the devforum, youtube and did some research about my problems on google but there isn’t any topic/video a way to fix my script.

I’d be appreciative if someone could help me with this.
Thanks!

local RS = game.ReplicatedStorage.vias:GetChildren()

for i = 0,1000 do
	local CloneModel = RS:Clone()
	CloneModel.Parent = game.Workspace
for _,V in pairs(RS) do
		V.Position = Vector3.new(-38.742, 15.539, -47.338)
	end
end

Reference the Model’s SetPrimaryPartCFrame property, provided you have a PrimaryPart already inserted

local RS = game.ReplicatedStorage.vias:GetChildren()

for i = 0,1000 do --Ok but why is this here
    for _, Model in pairs(RS) do
	    local CloneModel = Model:Clone()
	    CloneModel.Parent = game.Workspace
        CloneModel:SetPrimaryPartCFrame(CFrame.new(-38.742, 15.529, 47.338))
    end
end

I also just realized you’re attempting to clone a table of Instances, I don’t think you can do that? :thinking:

1 Like

This is correct in direct reference to CFrame. To move a model via position it is more proper to use :MoveTo().

:MoveTo() has obstruction checks which can be unreliable if the model needs to be relocated to an exact position.

Couldn’t you just move the PrimaryPart’s Position of the Model? Or would that only position that specific part?

MoveTo()'s function would rely on collisions, especially if you group Models close together

Then use Model:TranslateBy(). My argument for MoveTo over SetPrimaryPartCFrame exists in the fact that OP is asking to move via position.

it still doesn’t clone tho, no errors :confused:

I’m pretty sure by position he means that he just want to move the model, in this case both CFrame and Vector3 are applicable

1 Like

The cloning is a seperate issue because you are trying to clone a table.

I can’t clone through a table?

GetChildren() actually returns a table of all the Instances provided inside the vias object

You can try using this perhaps?

local RS = game.ReplicatedStorage.vias:GetChildren()

for _, Model in pairs(RS) do
    local CloneModel = Model:Clone()
	CloneModel.Parent = game.Workspace
    CloneModel:SetPrimaryPartCFrame(CFrame.new(-38.742, 15.529, 47.338)) 
end

You could use TranslateBy(), SetPrimaryPartCFrame(), MoveTo() (But that’d result in collision issues), or just referencing the PrimaryPart’s Position (Still unsure) for moving the model

1 Like

Why is this thread so long.

Just set a PrimaryPart to the Model then use :SetPrimaryPartCFrame, you are able to use a Vector3 position just do:

Model:SetPrimaryPartCFrame(CFrame.new(Vector3))
1 Like

I am getting this error…

SetPrimaryPartCFrame is not a valid member of MeshPart “Workspace.Meshes/ VFX_Sphere.002” -

O k a y t h e n

So if your vias Object has both Models & BaseParts inside, you should possibly implement conditional checks to make sure that each Object goes in their respective order to position them correctly

Maybe try this?

local RS = game.ReplicatedStorage.vias:GetChildren()

for _, Object in pairs(RS) do
    local CloneModel = Object:Clone()
	CloneModel.Parent = game.Workspace

    if CloneModel:IsA("BasePart") then
        CloneModel.Position = Vector3.new(-38.742, 15.529, 47.338)

    elseif CloneModel:IsA("Model") then
        CloneModel:SetPrimaryPartCFrame(CFrame.new(-38.742, 15.529, 47.338))
    end
end

it doesn’t clone the model but it only clone one part from the model then it stops… no error :confused:

theres a red line underline on line 4 (Model)

I did a dumb, replace that with Object

well, it does clone it but not in a model… is there a way for the model to clone it to the workspace instead of only 3 parts?

Wait, so you’re wanting to place all the parts cloned into a Model object is what I’m assuming? Try this then

local RS = game.ReplicatedStorage.vias:GetChildren()
local Model = Instance.new("Model")
Model.Parent = workspace

for _, Object in pairs(RS) do
    local CloneModel = Object:Clone()
    CloneModel.Parent = Model
    CloneModel.Position = Vector3.new(-38.742, 15.529, 47.338)
end

Bro, It worked!! Omg Thanks man!!