I'm trying to rotate a model using a script, and I'm using SetPrimaryCFrame. I can set the position (CFrame), but how do I set the rotation?
How do I rotate a model using a script?
1 answer
I would do
model.PrimaryPart = part --part = a random part in your model
model:SetPrimaryPartCFrame(CFrame.Angles()) --model = your model
--Put whatever you want to rotate the part by in the parenthesis.
8 comments
Oooh. So I can do it twice, once for position, and once for the rotation.
I'm doing it on a player. It first sets its CFrame as the same as the player's arm. Then I want to rotate it. But for some reason, it's off in the distance, and not on the arm. This only happens when I add CFrame.Angles
How much do you know about CFrames? It's hard to describe it in words but essentially, a CFrame is both an objects Position and Orientation, when you use CFrame.Angles you're only adjusting the rotation. It can be weird to get the positioning and orientation right because it rotates/moves around a set point which acts as the center. I'd advise reading up on CFrame.
Btw, I'm not exactly an expert when it comes to Lua myself, so don't take everything I say as fact, I'm only trying to point you in the right direction with my limited knowledge of CFrames.
What's the best way to get it to rotate around itself? Or can I change the rotation of the model using Vector3 and such?
Truthfully, I've never changed the CFrame of a Model, but I have done quite alot with CFrames otherwise and to my knowledge its impossible to rotate a Model around itself or using a Vector3 since a Model doesn't have an Orientation property.
Hopefully someone that knows more than me comes and helps because other than model:SetPrimaryPartCFrame(CFrame.Angles()) I'm as clueless as you :/
So how would I change to rotation if I have something attached to a player's arm?
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
CFrame.Angles()
Using SetPrimaryCFrame?
yes