Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to you rotate a model in a certain direction?

This is what I've tested

local cframe= CFrame.new(model.PrimaryPart.Position) -- CFrame with default rotation

model:SetPrimaryPartCFrame(cframe * CFrame.new(0, math.rad(90), 0))

and this

local Model = workspace.Model -- Replace this with your model.

Model:SetPrimaryPartCFrame(CFrame.new(0, math.deg(90), 0))

Both of them rotated my model 180 degrees and it did even if I put somthing else instead of 90

1 answer

The problem is that you are setting a new CFrame and not using the current CFrame of the model, you have also use CFrame.new instead of CFrame.Angles. You also need to be using radians with CFrame.Angles.

local Model = workspace.Model 
-- using the current CFrame rotate the CFrame by 90 degrees
Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(90), 0))

I hope this helps.

1 comment

0

Yes, but I want to set the rotation

This discussion is preserved as it was. New answers, comments, and votes are closed.