04 Roblox Lua Notes
All variables are global unless using local
Keywords & Such
- There is no ++ or --, same with && or ||. Instead its and, or, not. Also these work: +=, -=, <=, >=, ==
function = keyword used to create a function.
return = can be used to exit a function or go back into the function it was called in(hard to explain but the writer understands).
if then, else, & else if statements = Its obvious isn't it.
task.wait() = pauses the script for a certain amount of time.
break = stops loops when conditions are met.
continue = skips that iteration of the loop.
:Connect = connects events to scripts.
debounce = not a keyword, but a method to check whether something is being touched or not.
For
For MyLoop = 1, 5, 1 do
print("The first number is the starting number")
print("The second is the goal")
print("The last is the increment the first number adds(or substracts)")
end
While
local CoolNumber = 1
While CoolNumber <= 10 do
print("Remember to increment the variable you choose.")
print("If you don't, it will never end.")
CoolNumber += 1
end
Function
local function MyFunction(Number1, Number2)
local result = Number1 + Number2
print(result)
return result
end
print(MyFunction(5, 6))
print("You can insert variables in the () to use in the function.")
print("also you must have return in the function")