So here's my idea: I want to make an platform (a model) that can go up and down by itself, and rotate, However, i have no clue how to do it.
So far, here's what I know:
Model:SetPrimaryPartCFrame(CFrame.new(x,y,z))
Moves the model to that position,
Model:SetPrimaryPartCFrame(CFrame.Angles(rotation x, rotation y, rotation z))
Rotates the model accordingly. Combine them together,
Model:SetPrimaryPartCFrame(CFrame.new(x,y,z)) Model:SetPrimaryPartCFrame(CFrame.Angles(0, 0, math.rad(dn)))
And it only updates the angle of my model.
Any help would be appreciated.
Don't forget that CFrame
represents a position and a rotation matrix. The CFrame.new
constructor with only it's position field given (the first 3 arguments), yields no rotation. Likewise, the CFrame.Angles
constructor rotates a CFrame, but has no given position field (so it defaults to 0,0,0
).
In very few instances do you only care about rotation, and not position as well. Otherwise, you're rotating in relation to... what? The purpose of CFrame.Angles
is most effectively used as an operand for an existing CFrame. This way, you can maintain position while setting (or modifying) rotation. The solution? Multiplying them together.
Model:SetPrimaryPartCFrame(CFrame.new(x,y,z) * CFrame.Angles(x,y,z))
Hope this helped, let me know if you have any questions.