Positioning and orienting a model before adding it to the Workspace

I’m trying to position and orientate models before adding them to the Workspace. So far I can’t find any method for achieving this.

I tried setting the position and orientation of the models root part and then adding it to the workspace. I tested this using a dummy model.

DummyModel
PrimaryPart is the Head


Red is where I built the model before moving it into ServerStorage, green is where I’m trying to move it to.

Sample script

local serverStorage = game:GetService("ServerStorage")
local Dummy1 = serverStorage.Dummy1:Clone()

local endPosition = Vector3.new(8, 10, -31) --Starting position is (-32, 9, -31)
local endOrientation = Vector3.new(0,90,0) --Starting orientation is (0, -90, 0)

function spawnModel(Model)
	local Root = Model.PrimaryPart --Head is being used as the primary part
	
	Root.Position = endPosition
	Root.Orientation = endOrientation
	
	Model.Parent = game.Workspace
end

wait(5)

spawnModel(Dummy1)

When the script is executed the model is spawned in at its starting position.

Additional information
I tried using MoveTo() however this function didn’t seem to work untill I added the model to the workspace it also doesn’t allow me to change the models orientation.
This script works when the models primary part is the body (presumably because the body is touching all other parts) but for the purpose I’m trying to acheive the primary part isn’t touching any other part.

What you need is actually to change it’s CFrame. CFrame includes the position and orientation already. A CFrame.new() is two Vector3 s, with the first Vector3 being the Position and the next Vector being the look at Position.

To change the CFrame of a model, you need to use the function Model:SetPrimaryPartCFrame() . You might want to take a look at this article.

https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame

1 Like