Intro
Hello, Scripting in Lua can be very helpful.
For instance, Lua will help you make better places than those who cant script.
All though, When your learning Lua it can be Very difficult.
I'm still learning Lua aswell, Well Good luck in the scripting world of Lua!
Functions
Scripting is nothing without functions.
Functions are everywhere in the world of Lua.
Functions can be made or you can use already-made Functions such as
function
if
then
do
ect.
There are tons of functions!
- Code:
-
functionaoz = Instance.new("Function")
I think thats how you make a function.
Exscuse me if im wrong.
Functions are very Important
Properties
Almost everything has a property!
For instance Insert a brick from the Insert menu it doesnt matter what kind.
So, lets change the brick's name.
- Code:
-
game.Workspace.Part.Name = "HdFp02"
So to do it a more fun way you can do this
- Code:
-
game.Workspace.Part.Name = "Part"
wait(4)
game.Workspace.Part.Name = "KillerX210"
Then we made a name change more difficult by 1 percent but its cooler
say we wanna name it Kill Is COol 101
we say
- Code:
-
game.Workspace.Part.Name = ["Kill Is COol 101"]
Now changing reflectance brick color and transparency is the same
- Code:
-
game.Workspace.Part.Reflectance = 5.5 --That makes it reflectancy 5.5 it could also be Transparency just by changing reflectance to transparency
Now Brick color is a little more complicated
Ill cover it later
Now instead of saying game.Workspace.Part All the time you could create a Variable wich i will cover next!
Variables
A variable is kind of important to shorten scripts.
For instance intead of saying game.Workpace.Part all the time you could create a variable
Variables are Stuff that stand for stuff like z could mean Part
or Message or hint it can stand for almost everything
- Code:
-
Example: x = Instance.new("Message")
Now x stands for an Instance that is a message
or x = game.Workspace.Part
Now x stands for a Part
But x cannot have 2 values
so you could use a, b, c, d, e, f, g
But variables can go from as easy as L to as complicated as x2StarJammer/IncludedForYouToday
Variables can be anything of your choice
so
- Code:
-
CatInTheHat = Instance.new("Hint")
Now CatInTheHat is a Variable Meaning it stands for a hint!
Positioning
Positioning is Important in Lua to
There are 2 types of positions CFrame and Position
for instance i want to move a brick on the edge of another brick or in the air
Ex:
- Code:
-
game.Workspace.Part.Position = Vector3.new(10,10,10)
So we changed its position to X = 10 y = 10 and Z = 10
Vector3 is a Movement function so Vector 3 is the numerals meaning it needs 3 numerals. 10 10 10 is the Numerals.
Ex:
- Code:
-
game.Workspace.Part.CFrame.Value = Vector3.new(101,20,40)
Thats a CFrame Value their very Useful.
So i just made that brick collide with any brick near it or i changed its CFrame value.
Arguments
Arguments are very very important without an argument the script wouldn't work.
Ex :
- Code:
-
game.Workspace.Part.Position = Vector3.new(12,20,14)
Can you guess what the argument was there?
The argument passed there is 12 20 14 most arguments come before functions with a () or :
Ex:
- Code:
-
game.Workspace.Part.Position = Vector3.new(Cheezburger,2,10)
That wouldnt work because cheezburger isnt an argument but if you do this
- Code:
-
Cheezburger = 5
game.Workspace.Part.Position = Vector3.new(Cheezburger,2,10)
That would set the position to 5 2 10 Interesting right?
now watch this...
- Code:
-
game.Workspace.Part.Position = Vector3.new(a, b , c )
Same as cheezburger wont work but...
- Code:
-
a = 10
b = 10
c = 10
game.Workspace.Part.Position = Vector3.new(a, b, c)
That would work!
Isnt Positioning Fun?
Tables
Tables are used to store stuff in...
For example, ever seen a VIP door/ Admin script?
It says
- Code:
-
adminlist = {"raboy117"}
Thats a table...
just say
- Code:
-
coolppl = ("websiteRobloxYouNeedUs")
And to add on to that we do
- Code:
-
coolppl = ("websiteRobloxYouNeedUs","Roblox")
There we go!
and tables... Witch ill cover next.
MetaTables
Tables can have tables too!!!
--[[This is UNDER CPNSTRUCTION, Do not flame me, If you have any Ideas, Please message me on roblox or here, If you wish to help me out please give me suggestions for this. Thanks! ]]--