Rotate Parts of A Model With A Script

Hello! I am Making A Story Type Game Where i Want to Make Some Interactive Things.
Examples : Paintings Rotate 50 Degrees And Come Back to Normal after A Second When You Click Them.

Even Though I Have this Idea, I have No Clue on How i would Do This. Would i Use CFrame? If Yes,
Then How would i Use it for This?

The Model Has Two Parts. A Frame and A Screen i Want them Both to Rotate 50 Degrees When Clicked. (On Z Axis I think)

I have Inserted a Click Detector inside the Screen so when the The Player Clicks the Screen, The Painting Moves. But Now i Dont know What to Write in the Script.

Thanks for Reading! :slight_smile:

Hello. You can tween the CFrame of the required part.

You can try btools when its work?

I dont want to Smoothly Rotate it. It should be Instant. Like It rotates 50 degress then comes back to orignal

I think you may need to use SetPrimaryPartCFrame on the model for your case of instant movement

Example

Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(math.rad(50),0,0))

Where Model is the variable that contains the model, this would rotate it by 50 degrees in one axis

You may have to experiment with the 3 angles of CFrame.Angles, reminder that it only accepts radians so must use math.rad() when you have a non-zero degree

And another reminder, make sure the Model has a PrimaryPart set up, you can go into the Properties of the Model, click o nPrimaryPart, and select one of the 2 parts

3 Likes

why not use Part.Orientation?? because i used Part.Orientation and i got instant rotation

Because this is a model, that would only rotate a single part. Mine would rotate the entire model, given that the Model has a PrimaryPart set up

oh ok i didnt knew he was using a model thx for telling me!

1 Like

image

local Model = script.Parent
wait(10)
Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(math.rad(50),0,0))

You need to setup a PrimaryPart. Go into the Properties of the Model ,Click on the empty field near PrimaryPart, and click on a part in the model to set it as a PrimaryPart

2 Likes

Thank You So Much! It Worked When i tested It Out!

2 Likes

Glad that it worked! And since I didn’t mention about rotating it back, you can simply store the original CFrame in a variable and when you want it to return back, just set it back to the original CFrame

local Model = script.Parent
local originalCFrame = Model.PrimaryPart.CFrame
wait(10)
Model:SetPrimaryPartCFrame(originalCFrame * CFrame.Angles(math.rad(50),0,0))
wait(5)
Model:SetPrimaryPartCFrame(originalCFrame)

As an example. Or just use my CFrame.Angles example and just change the 50 to -50

2 Likes