Dictionaries, pairs, sorting and tables inside tables: how real games keep shops, inventories and player data.
A shop with pricesExerciseA dictionary keeps values by name. pairs goes over every key and value (in no fixed order).
The player ate the appleExercisetable.find gives a position, table.remove takes out what is there, and table.concat turns a list into text.
Top 3 playersExercisetable.sort(list, function(a, b) ... end) sorts in any order you want: return true when a comes first.
Everything about a playerExerciseTables inside tables: reach in with dots (data.stats.level) and with [ ] for lists (data.inventory[1]).
The empty shopDebugipairs is for lists (positions 1, 2, 3...). pairs is for dictionaries (and works on anything).
Quick checkQuizLists use positions, dictionaries use keys, and table.insert/find/remove/sort/concat do the rest.
2. Functions like a pro
Return several values, give defaults, pass functions around, make closures and format text: the tools behind every clean script.
A round timerExercisereturn a, b gives back two values, and local x, y = f() catches both.
The heal that crashedDebugA missing argument is nil. value = value or default gives it a default.
A function as a valueExerciseFunctions are values: they can be passed to other functions and called there (a callback).
A counter that remembersExerciseA closure: an inner function keeps the local variables it was made with.
A tidy status lineExercisestring.format fills %s, %d and %.1f with values. Text methods like :upper() and :sub() change texts.
Quick checkQuizMultiple returns, defaults with or, callbacks, closures and string.format.
3. Objects and classes
Methods with self, the colon that matters, an Enemy class you can make a hundred times, and modules shared between scripts.
A sword that swingsExercisefunction obj:method() gets the table as self. Call it with obj:method().
Dot or colon?DebugMethods made with : must be called with :. A dot does not pass self.
An Enemy classExerciseA class: methods in one table, __index pointing to it, and new making objects with setmetatable.
A shop moduleExerciseA module is a table of functions that a ModuleScript returns, so many scripts can use it with require.
Quick checkQuizMethods and self, classes with setmetatable/__index, and modules with require.
4. Working with the world
Clone templates, loop over folders, give objects your own attributes, and find things safely.
A row of coinsExercise:Clone() copies an object (and everything inside it). Set the copy's Parent to put it in the world.
Turn on the lightsExercise:GetChildren() lists what is inside an object, and :IsA("BasePart") tells parts apart from everything else.
Coins with different valuesExerciseSetAttribute/GetAttribute store your own values on objects, so one script can handle many different objects.
The missing keyDebugA dot fails when the child is missing. :FindFirstChild(name) gives nil instead, so you can check it.
Quick checkQuizClone, GetChildren with IsA, attributes, and FindFirstChild for things that may be missing.
5. Events like a pro
Debounce, buttons you click, Press E prompts, deaths and respawns, and events that run only once.
Spikes with a debounceExerciseTouched fires many times. A debounce (if busy then return end ... task.wait ... busy = false) makes it count once.
The coin worth 30DebugAn invisible part is still in the game. :Destroy() removes it and its connections.
A button to clickExerciseA ClickDetector makes a part clickable, and MouseClick gives you the player who clicked.
Press E to openExerciseA ProximityPrompt shows "Press E", and Triggered fires with the player who used it.
Count the deathsExerciseCharacterAdded fires for every new character, and Humanoid.Died fires when it dies.
A bonus only onceExercise:Once runs a handler only the first time. connection:Disconnect() stops a connection whenever you choose.
Quick checkQuizDebounce, Destroy vs Transparency, ClickDetector, ProximityPrompt, CharacterAdded and Died, Once and Disconnect.
6. Time and animation
Timers with task.wait, things that come back with task.delay, smooth movement with TweenService, and the loop that freezes a game.
Round starts in...Exercisetask.wait(seconds) pauses the script while the game goes on. for i = 5, 1, -1 counts down.
A coin that comes backExercisetask.delay(seconds, fn) runs fn later without stopping the script, great for respawning things.
A rising platformExerciseTweenService:Create(part, TweenInfo.new(seconds), goals) makes a smooth change, and :Play() starts it.
When the gate is openExercisetween.Completed fires when a tween finishes, so you can chain what comes next.
The game that frozeDebugA while true do loop must have a task.wait inside, or it freezes the game.
Quick checkQuiztask.wait, task.delay, TweenService with Play and Completed, and why every endless loop needs a wait.
7. Server and client
Where your code really runs, how the server and the players talk with RemoteEvents, and how to stop cheaters.
Server and clientTry itA RemoteEvent carries messages: FireServer on the client, OnServerEvent(player, ...) on the server.
Buying, the server wayExerciseThe server checks every request itself: the price comes from the server's own table, never from the client.
The free swordDebugNever trust the client: prices, damage and rewards are decided on the server.
A message to everyoneExerciseFireClient(player, ...) and FireAllClients(...) send from the server; the client listens with OnClientEvent.
Quick checkQuizServer and client, RemoteEvents both ways, and never trusting what the client sends.
8. Saving data
DataStores that remember every player: save when they leave, load when they come back, and stay safe when the servers fail.
Your first saveExerciseGetDataStore(name) opens a store; SetAsync(key, value) saves and GetAsync(key) loads.
Save when they leaveExerciseLoad in PlayerAdded (GetAsync(key) or 0), save in PlayerRemoving, with a key made from the UserId.
When saving failsExercisepcall(fn) catches errors: it gives ok (did it work?) and the result or the error message.
The lost coinsDebugSave and load with the exact same key, and build it from the UserId, which never changes.
Quick checkQuizDataStores with GetAsync/SetAsync, keys from the UserId, PlayerRemoving, and pcall for when things fail.
9. Advanced exam
Ten questions about everything in this course. Pass with 8 right answers.
The advanced Roblox examExamTables, functions, classes, the world, events, time, server and client, and saving data.
10. Final project
Build Coin Rush: cloned coins, prompts, timers and saved progress, in one game of your own. Then send it for review.
Coin RushFinal projectData, cloning, events, time, prompts and saving, all in one game: this is how real Roblox games are made.
How the course works
You learn by doing: each lesson explains one idea, then you write real code in the editor and see the result right away. The first lesson is free to try without an account; sign up to save your progress and continue.
Try it
Change working code and see the result immediately.
Exercise
Complete a task. A checklist confirms each requirement as you type.
Debug
Fix code that is broken on purpose, and learn why it failed.