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! :-)
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.