Hello guys, I recently started scripting and i want to know detailed about CFrame. I can't find the information i wanted on the web.. Please if you do know kindly take your time to explain and how to use it? I would really appreciate your help!
CFrame is a property of every basepart and it stands for coordinate frame. It is a matrix including 3 values for position and 9 values for rotation; completely describing its existence in the game. You HAVE to use CFrame if you want to manipulate an object in any advanced way.
wiki.roblox.com/index.php?title=CFrame
I'll explain some basics.
CFrame has "properties" that are just useful snippets of its values.
CFrame.p is position. CFrame - CFrame.p is rotation. CFrame.lookVector is the XYZ direction the part is facing as a unit vector. CFrame.upVector or .rightVector is lookVector orientated (I think).
CFrame has many useful functions too. Note none of these actually change the original, they only return a different CFrame.
CFrame:Inverse() is just a math function on the matrix. I can't say this is very useful to me. CFrame:lerp(newCFrame , alpha) gives you a CFrame that is between a desired CFrame by the alpha you specify between 0 and 1 (0%-100%). CFrame:toWorldSpace() places it in relation to (0,0,0) origin. Usually default. CFrame:toObjectSpace() places it in relation to a different object's position. Useful for welding.
And of course you can change the CFrame yourself with operations. It's a bit weird since it's a matrix. You can only multiply it by another CFrame or a vector and you can only add/subtract by a vector. One of the most useful things is to multiple by CFrame.Angles() for rotation. Good luck!