local)Used to store values like numbers, strings, booleans, or objects.
lua
CopyEdit
local name = "Player1"
local age = 16
local isActive = true
local makes it usable only in the current block or script.
Used to pause the script for a set amount of time (in seconds).
lua
CopyEdit
wait(1) -- pauses for 1 second
print("One second later...")
wait() defaults to a short delay (~1/30 sec).Used to make decisions based on conditions.
lua
CopyEdit
local health = 50
if health <= 0 then
print("Game Over")
elseif health < 100 then
print("Low Health")
else
print("Full Health")
end
Repeats code while a condition is true.
lua
CopyEdit
local count = 0
while count < 5 do
print(count)
count = count + 1
wait(1) -- optional delay so it doesnโt freeze the game
end
A for loop repeats code a set number of times.