Lua Programming

Programming is like giving step-by-step instructions to a computer to make it do things. Just like telling a friend how to build a Lego house, you write code for the computer to follow. In Roblox Studio, you use the Lua programming language to create games and bring your ideas to life. Lua is simple and powerful, making it perfect for beginners.

"Hello, world!"

function sayHello()
  print("Hello, world!")
end

Variables

local message = "Hello, Roblox!" 
print(message)
nila = nil
booleanb = true
numbern = 1
strings = 'abc'
tablet = {a, b, c}
functionfoo = function(x) return 2*x end
userdatau = some_C_struct
threadco = coroutine.create( function () print('hi') end )

Strings in Lua

local greeting = "Hello" 
local name = "Roblox" 
print(greeting .. ", " .. name)

Combining Numbers and Strings

local age = 10 
print("I am " .. age .. " years old")

Basic Arithmetic Operations

local x = 10 
local y = 20
print(x + y)
local a = 5 
local b = 3 
print(a * b)

Conditions

local number = 10 
if number > 5 then  
   print("Number is greater than 5") 
else 
   print("Number is 5 or less") end

Loops

for i = 1, 5 do 
   print("Iteration " .. i) 
end

Functions

function greet(name) 
   print("Hello, " .. name) 
end 
greet("Roblox")
greet("Game")

If you found this tutorial helpful and would like to support my work, please consider buying me a coffee.

Thank you very much for your support!

Buy me a coffee