Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to rotate a Model?

Asked by 10 years ago

Hey people! I've recently just figured out how to CFrame -- or move -- Models using MoveTo(), and it has helped me immensely. The thing is, now I want to learn how to rotate a model. It would be VERY helpful if anyone could teach me this skill, because I'm having trouble rotating the WHOLE Model instead of just its individual pieces. Thanks!

1 answer

Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

Yes, there is a way.

Arguments for the function:

function TransformModel(table objects, CFrame center, CFrame new_center[, bool recursive])

Code:

function TransformModel(objects, center, new, recurse)
    for _, object in pairs(objects) do
        if object:isA("BasePart") then
            object.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame))
        end

        if recurse then
            TransformModel(object:children(), center, new, true)
        end
    end
end

local Model = game.Workspace.ModelToRotate

TransformModel(Model:children(), Model:GetModelCFrame(), Model:GetModelCFrame() * CFrame.new(0, math.rad(45), 0), true) -- Rotates the model 45*.
0
Wait. What does argument and code mean? Sorry, I'm a bit of a beginner on this. Do I put them both in separate scripts, or what? dpark19285 375 — 10y
0
Arguments are the inputs to the function. The code is the actual script. The bottom one is the one you use. Tkdriverx 514 — 9y
Ad

Answer this question