To rotate a model by script in roblox studio is probably very simple. But I havn't been able to do it. So my qustion is how to rotate a model by script. Do you use CFrame? I'm pretty new to roblox lua.
i know this thread is old but i think other people would get helped if this got resolved, to rotate it you can almost use BlackJPIs script just a small change
local cframe = model.PrimaryPart.CFrame -- Current CFrame model:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(90), 0))
Like you see its only the CFrame.new thing ive changed to CFrame.Angles, when you make .new it will make a new CFrame position and Angles will put its orientation, hope some people have use of this!
The best way to rotate a model is by using the SetPrimaryPartCFrame
function.
It will take a model and rotate it around its PrimaryPart
. Note that you will have to set that before using it, or you'll see an error. You can do that in the Properties window.
For example, this will rotate the model 90 degrees along its Y axis:
local Model = workspace.Model -- Replace this with your model. Model:SetPrimaryPartCFrame(CFrame.new(0, math.deg(90), 0))
IDidMakeThat has the correct procedure but has some errors in his implementation.
He is setting the PrimaryPart's CFrame to the position (0, 5156.62, 0). Also, math.deg
takes an argument in radians and gives you that value in degrees. So you'll want to use math.rad
.
Examples
This example will rotate the model by a given amount from its current position:
local cframe = model.PrimaryPart.CFrame -- Current CFrame model:SetPrimaryPartCFrame(cframe * CFrame.new(0, math.rad(90), 0))
This example will set the model's rotation instead of rotating from its current position:
local cframe= CFrame.new(model.PrimaryPart.Position) -- CFrame with default rotation model:SetPrimaryPartCFrame(cframe * CFrame.new(0, math.rad(90), 0))
Locked by JesseSong
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?