Hello, I’m relatively new to scripting and have a hard time understanding CFrame and how it works, I’ve used CFrame in the past like making the HumanoidRootPart’s CFrame to match a part to then teleport the player, but I still don’t know how a CFrame’s position and orientation are any different.
Can someone give me examples of a part’s CFrame position and orientation and how I’d apply that, not like a big chunk of code by like “Part1.CFrame = Part2.CFrame” and how you’d get the rotation/orientation of a part with CFrame. I’m new to CFrame and I understand it’s uses and need to improve.
Any and all help is appreciated, means a lot to me even if you simply took the time to read this.
from what I understand, CFrame is basically the parts current position in vector 3 (vector 3 is X,Y,Z in that order) however position is the value of the Cframe, so its basically the same thing. so you would use
local part = game.Workspace.Part
local block = game.Workspace.Block
part.CFrame = CFrame.new() -- creates a new Cframe for the part
--then add the blocks position
part.CFrame = CFrame.new(game.Workspace.Block.Position) -- adds the position of "block"
``` that will move the part to the block.
orientation is the rotation of the part in x,y,z. Its a little more confusing but same concept.
local part = workspace.Part
part.Orientation = Vector3.new(0, 0, 0) --rotates the part
make sure to use vector3.new for orientation and Cframe.new for cframes