How to change the Orientation of a model by a script?

is it possiblet o change the orientation of a model?

9 Likes

Get the model’s children and change their orientation

Solution 1:

for _, v in pairs(modelObject:GetChildren()) do
    v.Orientation = Vector3.new(0,0,0)
end

or the way I would do it in my scripts is use CFrame like so

for _, v in pairs(modelObject:GetChildren()) do
    v.CFrame = CFrame.Angles(math.rad(90),0,0) --math.rad is needed for radians when using CFrame.Angles
end

Make sure everything in the model has the property of orientation or it will give an error.

Solution 2:
You can also make a primary part of the model and weld all it’s children then rotate the main part and all the other parts welded to it will move or rotate accordingly.

Edit: Also next time please give more details in your description as to what you have tried as code so people would want to help you.

21 Likes

Yes. If you set the primary part of the model you can do :SetPrimaryPartCFrame() on it. This will rotate all parts about the primary part. This differ’s from uhi_o’s answer as his will individually rotate each part 90 degrees.

15 Likes