By DerAtomik
Editors: Zaqre
Properties
Every object in ROBLOX has properties. Properties is basically what makes up that object. A Part has many properties, including ones that affect its transparency, collision, and surfaces. Every ROBLOX object shares the following properties: Name (Obvious), ClassName (The type of Instance), & Archivable (Whether this object will be cloned when the Clone method is called on it or one of its ancestors). You’ll have to read the ROBLOX Wiki for information on properties of objects. Almost every object has at least one unique property.
Example
--This makes a player die when they touch the brick script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = 0 --Health is the property we're setting end end)
Math
You can perform many complicated mathematical functions in Lua, but lets focus on the basics. You would write an equation as you would in real life. Such as “2 + 2.” However, you do not need to always space the numbers and signs. As I said in my previous Beginner Lua Lesson, you can use numbers with if statements. And, you can use parenthesis to separate equations on the same line. Here are the rest of the symbols used for calculating basic math: Division: / (forward slash), Multiplication: * (asterisk), Subtraction: – (hyphen). As well, you might notice the word “math” is bold and blue in Lua. This is because you can use it to call upon more complicated functions. The most common being math.random. Math Function Dump
String
In Lua, a string is basically text. It can be applied to any property that involves text as its value, such as the Name of an object or a Gui’s text. A string is created by putting text inside quotation marks “, apostrophes ‘, or two left and right angle brackets [[ ]]. As well, you can add onto a string by using two periods (..) to add on to the string (can be performed several times, order matters). Just like math, there are more complicated string functions. String Function Dump
Example for Math and String
game.Players.PlayerAdded:connect(function(player) local years = player.AccountAge/365 --AccountAge is in days print(player.Name.." has been on ROBLOX for approximately "..years.." years.") end)