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 a script?

Asked by
Jexpler 63
5 years ago

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?

0
CFrame.Angles() INOOBE_YT 387 — 5y
0
Using SetPrimaryCFrame? Jexpler 63 — 5y
0
yes greatneil80 2647 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.
0
Oooh. So I can do it twice, once for position, and once for the rotation. Jexpler 63 — 5y
0
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 Jexpler 63 — 5y
0
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. nicktooner 119 — 5y
0
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. nicktooner 119 — 5y
View all comments (4 more)
0
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? Jexpler 63 — 5y
0
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. nicktooner 119 — 5y
0
Hopefully someone that knows more than me comes and helps because other than model:SetPrimaryPartCFrame(CFrame.Angles()) I'm as clueless as you :/ nicktooner 119 — 5y
0
So how would I change to rotation if I have something attached to a player's arm? Jexpler 63 — 5y
Ad

Answer this question