Make your game smooth — measure first, then attack the three biggest costs — parts, loops, and events.
Your game works. Now make it smooth. Performance is a budget, and this lesson shows you where beginner games spend it wastefully — and how to measure before you fix anything.
A game running at 60 FPS has about 16 milliseconds per frame to do everything — physics, , rendering. Cross the budget and frames drop:
Optimization is spending that budget on things the actually notices.
At 60 FPS, how long does each frame have to do all its work?
The #1 optimization rule: don't guess what's slow. Guessing wastes hours and often fixes nothing.
Open View → Stats in Studio and watch three numbers while you play:
Roblox ships a deeper tool, the MicroProfiler, that breaks down every task per frame. You don't need it yet — the Stats window is enough to find beginner problems.
The same three costs eat beginner games over and over: , , and . Fix those and you've fixed most of it.
Your game is laggy. What's the correct first step?
Each costs memory, physics, and rendering time — even if it never moves. A field of 500 tiny coins is 500 bills.
Ways the cost grows fast:
Instance.new("Part") inside .The fix is rarely "no ." It's fewer, smarter :
part:Destroy() when they're done — don't just hide them.A part that never moves should be so the physics engine stops simulating it.
A bare while true do body runs as fast as Luau can — often hundreds of times per second. If that body does anything at all, you're burning the frame budget on work nobody sees.
-- ❌ spins flat-out, burning CPU
while true do
print("still here")
end
-- ✅ does the same job, twice a second
while true do
print("still here")
task.wait(0.5)
end
Rule of thumb: put a task.wait in every , and make the delay as large as the job allows. Decorative and UI can wait 0.1–0.5 s; -facing logic can be snappier.
while true do
local players = game.Players.NumPlayers
-- runs every frame: nothing to see, everything to waste
end
Add the missing line that stops this loop from spinning flat-out.
Connections are cheap to make and cheap to leave — which is exactly how they pile up:
The pattern to learn: connect once, disconnect when done.
local connection = part.Touched:Connect(onTouch)
-- when the part is gone, so is the connection:
connection:Disconnect()
Next: performance is measured on the 's machine — the frame budget, the per-frame work that eats it, and how to measure before you optimize.