💡 Variables store values you can use later.
local playerName = "Bob" -- String
local score = 100 -- Number
local isAlive = true -- Boolean
✅ Use local for variables.
✅ Strings can use " or the modern backtick interpolation:
print(`Hello {playerName}`) -- Shows: Hello Bob (using the above listed playerName)
Functions let you reuse code easily.
local function greet(name)
print(`Hello {name}`)
end
greet("Player1")
Repeat actions with loops.
for i = 1, 5 do
print(i)
end
while score > 0 do
score -= 1 -- This is the same as `score = score - 1`
end
Make decisions with if, elseif, else.
if isAlive then
print("Keep going!")
else
print("Game Over")
end