First of all, to give you all an idea of my skill level, I would like to say that I'm a beginner. I am not a fresh beginner that I need to read the wiki for more, I already know the basic things.
What exactly is SetPrimaryPartCFrame? If you have a model with multiple parts that you want to cframe rotate (possibly with CFrame.angles) could I use that?
I am making a simple script where you can click a box and it flips open.(Not simple for me, because I made the top lid of the box decorated/multiple parts)
Thanks in advance.
The wiki is a great place to learn new things, and learning from it does not mean you are a beginner.
To open the lid of a box as you stated above, you will need to make a model of only the parts of the lid, and select any part to become the PrimaryPart of the model by going in the properties of the model and clicking on PrimaryPart, this allows you to set the PrimaryPart.
Now once this step is done, you can use SetPrimaryPartCFrame and GetPrimaryPartCFrame to be able to rotate the model resulting in the lid opening.
SetPrimaryPartCFrame basically moves / rotates the primary part according to the CFrame assigned to it and keeps the orientation and offset of all the parts inside the model.
GetPrimaryPartCFrame returns the current CFrame of the primary part of the model
Code:
local model = script.Parent model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, math.rad(45)) -- assuming you want it to rotate 45 degrees on the z-axis
Hope it helped!