CFraming
In most popular games on ROBLOX, the building is as good as the scripting. Being able to build on ROBLOX is very important, so this tutorial will teach you the basics.
We'll start with CFraming. CFrame stands for coordinate frame. "CFraming" on ROBLOX usually refers to rotating parts, or putting them in positions you normally couldn't. You can CFrame through scripts, but most ROBLOXians just use the Command line. Here is a basic CFrame script you might see:
game.Selection:Get()[1].CFrame = game.Selection:Get()[1].CFrame * CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
Woah! That code is complicated. Let's break it down:
game.Selection:Get()[1] -- Creates a table of your selection, and indexes the first key
.CFrame = game.Selection:Get()[1].CFrame -- Changes the CFrame value of the selection to a modified version:
* CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0) -- Changes the positon and rotation of the selection
To use this script, paste it into the Command line. Click on a part, and change one of the '0s' to a number of your choice. It will move/rotate the selection that many studs. It moves parts in the following format: CFrame.new(X,Y,Z) and CFrame.Angles(X,Y,Z)
So, to move the part up, change the 2nd 0 to a positive number. To move it the opposite direction, use a negative number. Just replace the zeros with any number you like to move and rotate. Many users use tenths, or even hundredths, of studs.
We'll start with CFraming. CFrame stands for coordinate frame. "CFraming" on ROBLOX usually refers to rotating parts, or putting them in positions you normally couldn't. You can CFrame through scripts, but most ROBLOXians just use the Command line. Here is a basic CFrame script you might see:
game.Selection:Get()[1].CFrame = game.Selection:Get()[1].CFrame * CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
Woah! That code is complicated. Let's break it down:
game.Selection:Get()[1] -- Creates a table of your selection, and indexes the first key
.CFrame = game.Selection:Get()[1].CFrame -- Changes the CFrame value of the selection to a modified version:
* CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0) -- Changes the positon and rotation of the selection
To use this script, paste it into the Command line. Click on a part, and change one of the '0s' to a number of your choice. It will move/rotate the selection that many studs. It moves parts in the following format: CFrame.new(X,Y,Z) and CFrame.Angles(X,Y,Z)
So, to move the part up, change the 2nd 0 to a positive number. To move it the opposite direction, use a negative number. Just replace the zeros with any number you like to move and rotate. Many users use tenths, or even hundredths, of studs.
CFraming with Scripts
![Picture](/uploads/2/5/9/5/2595885/6500656.gif)
Now that you know how to CFrame, it's time to CFrame in scripts. You can do this just like in the Command line. For example, making a door open with a script:
for i = 1, 20 do -- for loop
workspace.Part.CFrame = workspace.Part.CFrame + Vector3.new(0, i, 0) -- Move part
wait(0.1) -- wait
end -- end
This could be combined with a simple function for an awesome door!
for i = 1, 20 do -- for loop
workspace.Part.CFrame = workspace.Part.CFrame + Vector3.new(0, i, 0) -- Move part
wait(0.1) -- wait
end -- end
This could be combined with a simple function for an awesome door!
Meshes and Other Parts
![Picture](/uploads/2/5/9/5/2595885/2011764.png?212)
You can't build much with normal parts. When you resize them and add meshes, you can do a lot. To insert a Mesh, click on a part. Go to the Insert>Object menu. Insert a SpecialMesh, or any other type of mesh. If you use a SpecialMesh, take a look at the properties menu. Use MeshType to change the shape. You can edit the Scale to resize your mesh. Use MeshId to add a custom mesh made by ROBLOX. Use TextureId to change a mesh's texture, like you would when retexturing. Try editing these values with scripts!