CFrame is used in alot of scripts and I have no idea what it is, how to use it, or even what it is used for. Please help.
CFrame is very simply a database containing both position and orientation. There are loads of uses for CFrame such as creating beams from raycasting, rotating parts, and even teleporting players. I'll show you some examples below. (Note: I will be putting the things in --comments
.) for moving parts alone, I just recommend you use Vector3
.
Rotating the part's orientation
local part = workspace.Part part.CFrame = CFrame.Angles(0,math.rad(90),0) --This changes the angle of the part, however, it resets the position to 0,0,0. So you need to do something like this: part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(90),0) --using the * is like adding.
Teleporting the player to another part (Not to be confused with TeleportService)
local part = workspace.Part for i, v in pairs(game.Players:GetPlayers()) do --This gets the players. local character = v.Character character.HumanoidRootPart = part.CFrame --This teleports the player to the part, however, make sure collision is off and the part is transparent. If you use typical Vector3, it would instantly kill the player. end
CFrame is an objects position and orientation in the workspace. You would use it to move a part (or model) , locate parts etc.
Heyyy, maybe you could refer to some of these recourses:)
https://www.youtube.com/watch?v=VxgNleUdmmg https://www.youtube.com/watch?v=9YqN8_VERps