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

How do I rotate a Model using CFrame?

Asked by 7 years ago

I've just begun experimenting with CFrames today and it's been giving me a headache. I've been making plenty of desperate attempts on finding a way to rotate an entire model, and CFrame seems to be the one that is the most popular/mentioned so I went and give it a shot.

Here's my code if you're wondering what I've been up to. Note: The "????" is the part where I don't know what to put to rotate the model.

------- Code begins here -------

local model = game.Workspace:WaitForChild('Model') local modelgetchildren = model:GetChildren() local mouse = game.Players.LocalPlayer:GetMouse()

model.PrimaryPart = model:FindFirstChild('Part') mouse.TargetFilter = model

mouse.Move:connect(function() model:MoveTo(mouse.Hit.p) end)

mouse.KeyDown:connect(function(key) if key == 'r' then model:SetPrimaryPartCFrame(????) end end)

------- Code ends here -------

Thank you for reading this question and I hope you will spare some time to help me with this obnoxious (but important as it is a crucial element for my game) task!

P.S. This is my first 10 minutes into the community! Hi guys! :-)

1
Can you pls fix the code block. User#5423 17 — 7y
0
It depends on how you want it to be rotated, (like how much, etc.) Perci1 4988 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

CFrame.Angles can help you accomplish this task. What it does is basically rotates the CFrame that you are multiplying it by by the degrees that you put in it as it's parameters. modelCFrame*CFrame.Angles(90,0,0) rotates the CFrame modelCFrame (a variable) by 90 degrees.

Ad

Answer this question