Learn Lua

Welcome to the Lua learning for roblox studio super easy to get started!

Printing in lua is this way

print("Hello, Roblox!")

Variables its just like python but just with the start local

local name = "John" local age = 30 local height = 5.9

Data types: its used to store data  Lua supports basic data types such as strings, numbers (both integers and floats), booleans, and tables.

local str = "Hello" local num = 42 local pi = 3.14 local isTrue = true local myTable = {1, 2, 3}

Basic Operations: Lua supports standard arithmetic operations like addition, subtraction, multiplication, division, etc.

local a = 10 local b = 5 local addition = a + b local subtraction = a - b local multiplication = a * b local division = a / b

Conditional Statements: You can use if, elseif, and else to control the flow of your code based on conditions.

local x = 10 if x > 5 then print("x is greater than 5") elseif x == 5 then print("x is equal to 5") else print("x is less than 5") end

adding Loops: its just like you looping a video but with code instead

-- For loop for i = 1, 5 do print(i) end -- While loop local count = 0 while count < 5 do print(count) count = count + 1 end -- Repeat-until loop local num = 5 repeat print(num) num = num - 1 until num == 0

Functions:Functions are reusable blocks of code that can take inputs (parameters) and return outputs.

function addNumbers(a, b) return a + b end local result = addNumbers(2, 3) -- result will be 5

and Finally Comments its to tell something or how it works and such other

Example -- made by Dannyi

this tutorial is now done if you want to learn python tutorial click this button below if you want advanced classes for lua you need to Pay $10 for an advanced class