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

How to set model rotation?

Asked by
ItsMeKlc 235 Moderation Voter
8 years ago

Heyo, I wan't to set a model rotation, this works kinda works but it adds on to the rotation. So how would I set it and not just add on to the rotation amount?

I'm sorry if I'm not making sense I just don't know how to explain it.... Basically I want the rotation = what I set and not the original rotation+what I set

function rotatemodel(model,center,rotation)
    for i,v in ipairs(model:GetChildren()) do
        if v:IsA("BasePart") then
        v.CFrame=((CFrame.new(center)*rotation)*CFrame.new((v.Position-center)))*(v.CFrame-v.Position)
        --elseif v:IsA("Model")or v:IsA("Folder") then
        --rotatemodel(model,center,rotation)
        end 
    end
end
local tabel = game.Workspace["Red Couch"]
rotatemodel(tabel,tabel.Base.Position,CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0)))

2 answers

Log in to vote
1
Answered by
Azmidium 388 Moderation Voter
8 years ago

You can put an invisible part in the very middle of your model, and set the PrimaryPart to that part. After you can just modify that part with :setPrimaryPartCFrame and it will mess with the whole model. Basically you can rotate, and position the whole model through that one part. :)

Hope this helped!

Sincerely, jmanrock123

0
game.Workspace["Red Couch"]:setPrimaryPartCFrame(game.Workspace["Red Couch"].Base.CFrame*CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0))) ItsMeKlc 235 — 8y
0
That does the same thing, how would I fix that? ItsMeKlc 235 — 8y
Ad
Log in to vote
0
Answered by
ItsMeKlc 235 Moderation Voter
8 years ago

`local x, y, z = game.Workspace["Red Couch"].Base.CFrame:toEulerAnglesXYZ() game.Workspace["Red Couch"]:setPrimaryPartCFrame(game.Workspace["Red Couch"].Base.CFrameCFrame.Angles(x-1, y-1, z-1)*CFrame.Angles(math.rad(-0), math.rad(22.5), math.rad(0)))

`

Answer this question