You do not need to memorize every Roblox API. Learn how to store a value, make a decision, name a reusable action, and react to an event. Those four skills make most beginner scripts much easier to read.
Variables and values
A variable gives a value a name. local limits that name to its scope. Numbers, strings, and booleans are common starting points.
local coins = 0local playerMessage = "Welcome!"local roundRunning = truecoins = coins + 1print(playerMessage, coins)Conditions
An if statement runs code only when a condition is true. Use == to compare values; one = assigns a value. This example only prints a message—it does not award anything.
local coins = 12if coins >= 10 then print("You have enough coins")endFunctions
A function groups steps under a name. Parameters are inputs; return sends a result back to the caller.
local function addCoins(current, reward) return current + rewardendlocal total = addCoins(10, 5)print(total) -- 15Events
An event tells your code something happened. Connect attaches a function to that event. Put this Script inside an anchored Part, then touch it in Play mode:
local part = script.Parentpart.Touched:Connect(function(hit) print("Touched by", hit.Name)end)A touch can fire more than once. Add a cooldown when the action should happen at most once in a short period; the color brick tutorial shows how.
Practice one change
- Predict what a script will do before running it.
- Change one value and test your prediction.
- Use Output to inspect intermediate values.
- Explain the script in your own words before adding more code.
Build your next small idea.
Try the generator