iProductKeys

How to Script in Roblox Studio (Beginner’s Guide)

How to Script in Roblox Studio (Beginner's Guide)

Learning how to script in Roblox Studio is easier than most beginners expect. You do not need to know how to code already. Roblox Studio is free, the scripting language is friendly, and your very first script can be running in under ten minutes. This guide takes you from zero to a working game script.

Scripting is what turns a Roblox place from a static map into a game. Without scripts, parts just sit there. With scripts, doors open, bricks hurt, and coins count up. Every game you love on Roblox runs on scripts like the ones you are about to write — yours is five lines long, theirs is thousands, but both start the same way.

What You Need Before You Start

Three things, and you probably have all of them already.

A free Roblox account. You need an account to open Roblox Studio and save your work. If you already play Roblox, you have one. If not, making one takes two minutes on the Roblox website.

Roblox Studio, installed on your computer. Roblox Studio is the free program creators use to build Roblox games. Download it from the Roblox Creator Hub at create.roblox.com and install it like any other program. It works on Windows and Mac.

About 30 minutes. The first script takes about ten minutes, and the kill brick and leaderboard take another twenty. Give yourself half an hour.

You do not need a fast computer, a paid plan, or any coding experience. Roblox Studio runs on ordinary laptops.

Roblox Studio interface with Explorer and Properties panels

Your First Script in Roblox Studio

Your first script will do one simple thing: print the words “Hello, World!” in the Output window. Every programmer starts here, because it proves your setup works before you build anything bigger. Follow the steps in order.

Follow These Steps

  1. Open Roblox Studio and choose the Baseplate template. A flat green baseplate appears in the middle of your screen. This is your empty world.
  2. Click the View tab at the top of the screen, then click Explorer. A panel opens on the right with a list of everything in your game. This list is called the Explorer.
  3. In the Explorer, find ServerScriptService. It is the folder where server scripts live. Hover over it with your mouse and click the small + button that appears.
  4. A menu opens. Click Script. A new script appears in the Explorer, and a code editor opens with one line already in it: print(“Hello, World!”).
  5. Do not change anything yet. Look at the code. The word print tells Roblox to show a message, and the words inside the round brackets and quotes are the message itself.
  6. Click the View tab again and click Output. A panel opens at the bottom of the screen, where messages from your scripts appear.
  7. Now press the big Play button at the top of the screen, or press F5 on your keyboard. Your game starts running.
  8. Look at the Output window. You should see the words Hello, World! printed there. That is your script running. You just wrote your first working program.
  9. Press the red Stop button at the top of the screen to stop the game. Your script stops too.

If you saw Hello, World! in the Output window, everything works. If you saw nothing, check that the script is inside ServerScriptService and that you pressed Play. Scripts only run while the game is playing.

Lua code editor showing print Hello World in Roblox Studio

How Scripts Work in Roblox Studio

Roblox has three kinds of script, and knowing which one to use is half of scripting. Pick the wrong kind and your code will run in the wrong place — or not run at all.

Script — the server script

A Script runs on the server. It controls things every player sees: the world, the parts, the points, the rules. The kill brick and the leaderboard in this guide are both server Scripts. When you are not sure which kind to use, start with a Script. It is the default, and it is the right choice for most beginner projects.

LocalScript — the client script

A LocalScript runs on one player’s device, not on the server. It controls things only that player sees: the camera, the screen, buttons, and menus. It only works in certain places — StarterPlayerScripts, StarterCharacterScripts, StarterGui, or inside the player’s character. Put one anywhere else and it will not run. Beginners rarely need LocalScripts.

ModuleScript — the shared code library

A ModuleScript holds code that other scripts can share. It returns a table of functions, and other scripts load it with require(). Think of it as a toolbox: you write a useful function once, and every script in your game can use it. You do not need ModuleScripts for your first game.

The language itself is called Luau. It is Roblox’s version of Lua, a small and friendly programming language. You will see the words Lua and Luau used for the same thing — Lua is what most people search for, Luau is the correct name inside Roblox.

Three ideas carry the whole language. A variable stores a value, like local score = 0. An event waits for something to happen, like a player touching a brick. A function is a block of code with a name, so you can run it whenever you need it.

Second Example: The Kill Brick Script

The kill brick is the classic first script every Roblox beginner searches for — a brick that damages any player who touches it. You have probably walked into one in an obby. Here is how to make your own.

First, build the brick. In the Explorer, hover over Workspace, click the + button, and add a Part. In the Properties panel, set its color to bright red so you can spot it, and make it about 4 studs wide. Move it onto your baseplate. Then click the part, and in the Explorer, hover over the part, click +, and add a Script inside it. The script must live inside the brick, not in ServerScriptService.

Now delete the print line in the editor and paste this code instead:

local killBrick = script.Parent

local function onTouched(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid:TakeDamage(100)
	end
end

killBrick.Touched:Connect(onTouched)

Here is what each line does. The first line saves the brick itself into a variable called killBrick — the script is inside the brick, so script.Parent means the brick. The second line starts a function called onTouched, which runs every time something touches the brick. Inside it, the code looks for a Humanoid — the part of a player that holds their health — in whatever touched the brick. If it finds one, TakeDamage(100) takes away 100 health, a full health bar. The last line connects the function to the brick’s Touched event.

Press Play and walk your character onto the red brick. Your character resets and appears back at the spawn point. That is the kill brick working. Walk around it instead, and nothing happens — the script only fires on a touch.

If it does not work, check three things: the script is inside the part, not in ServerScriptService; it is a Script, not a LocalScript; and the part is touchable — CanTouch is on by default, so leave it alone unless you changed it.

Red kill brick on a Roblox obby course

Third Example: A Simple Leaderboard

Most Roblox games show a leaderboard — a list of players and their points, coins, or wins. Here is the simplest version: every player gets a Coins score that starts at zero.

In the Explorer, hover over ServerScriptService, click +, and add a new Script. Delete the print line and paste this code:

local Players = game:GetService("Players")

local function onPlayerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = 0
	coins.Parent = leaderstats
end

Players.PlayerAdded:Connect(onPlayerAdded)

The folder must be named exactly “leaderstats” — all one word, lowercase l, capital s at the end of “leader”. Roblox looks for that exact name, and if you spell it differently, no leaderboard appears. The IntValue inside it is the score. Name it “Coins” and it shows up as a Coins column. Change the name and the column changes with it.

Press Play. Look at the top right of your game screen. Your name appears on the leaderboard with 0 Coins next to it. The leaderboard is working.

To make the coins do something, you need a second script that adds to them — for example, a coin part that gives +1 when a player touches it. That script follows the same pattern as the kill brick: a Touched event, a Humanoid check, and one new line that adds to the Coins value. If you can read the kill brick code, you can write the coin code.

One honest note: this leaderboard resets every time a player leaves. Saving scores between sessions needs DataStores, which is a bigger topic for your next tutorial.

Roblox leaderboard showing player coins

Common Mistakes (and How to Fix Them)

Every beginner hits the same handful of errors. Here are the ones that cost the most time.

Nothing happens when I press Play. The script is probably in the wrong place. Server Scripts belong in ServerScriptService or inside a part. LocalScripts only work in StarterPlayerScripts, StarterCharacterScripts, StarterGui, or the character.

The Output window shows a red error. Read it. Roblox errors say exactly what is wrong and on which line. The most common cause is a typo: a missing end, a missing bracket, or a capital letter in the wrong place. Luau cares about capitals — TakeDamage works, takedamage does not.

My kill brick kills me when I spawn. Your spawn point is too close to the brick, or the brick is under it. Move the brick away from the spawn location, or move the spawn point to the other side of the baseplate.

The leaderboard does not show up. The folder name must be exactly “leaderstats”. Check the spelling letter by letter. Also check that the script is a server Script in ServerScriptService, not a LocalScript.

My code worked, then I changed one line and everything broke. Change one thing at a time and test after each change. When ten changes go in at once and something breaks, you cannot tell which one did it. One change, one test, and the error is always in the last thing you touched.

Copied Scripts and Staying Safe

I copied a script from a video and it does not work. Old tutorials use old Roblox features, and some scripts online are written for games that no longer exist. The code in this guide is written for Roblox Studio as it works today. If a copied script fails, read its error in the Output window first — the error usually names the broken line.

One thing never to do. Never download a “script executor” or a “free scripts” program from the internet, and never paste code from a site that promises free Robux or cheats. Those programs break the Roblox rules, they can get your account banned, and they are a well-known way for bad software to get onto your computer. Everything a beginner needs is inside Roblox Studio itself.

Testing a Roblox game with the Play button in Roblox Studio

Helpful Tips

Helpful Tips

➤ Keep the Output window open while you work. It tells you when a script runs, what it printed, and exactly where an error is.

➤ Test after every small change. One change, one Play press. Finding a bug in one new line takes seconds; finding it in fifty takes an hour.

➤ Name your parts and scripts clearly. “KillBrick” and “CoinPart” are easy to find in the Explorer; “Part” and “Part (2)” are not.

➤ Save often. Use File, then Save to Roblox As, and give your place a name. Studio can close unexpectedly, and a saved place is never lost.

➤ Read the error before you change anything. The red text in the Output window names the line and the problem — it is the fastest teacher you have.

➤ Build the obby first, script second. A finished map with no scripts is a good day. A pile of scripts with no map is a headache.

Frequently Asked Questions

Is Roblox Studio free?

Yes. Roblox Studio is free to download, a Roblox account is free to make, and publishing a game is free too. You only pay if you choose optional extras later, like Robux for ads. Everything in this guide costs nothing.

Do I need to know how to code before I start scripting in Roblox Studio?

No. Luau is a beginner-friendly language, and this guide assumes you have never written a line of code. You only need three ideas to start: variables store values, events wait for something to happen, and functions are named blocks of code. The first script in this guide is one line long.

What is the difference between Lua and Luau?

Luau is Roblox’s version of Lua. The basics are the same — print, variables, functions, events — and Luau adds a few extra features on top. Most people search for “Lua” when they mean Roblox scripting, so this guide uses both words. The code is the same either way.

What is the difference between a Script and a LocalScript?

A Script runs on the server and controls things every player sees — the world, the parts, the points, the rules. A LocalScript runs on one player’s device and controls things only that player sees — the camera, the screen, buttons, and menus. A LocalScript also only works in a few places, like StarterPlayerScripts or StarterGui. Put one anywhere else and it will not run. Beginners should start with server Scripts.

Why is my Roblox script not working?

Check four things, in this order. First, is the script in the right place — a server Script in ServerScriptService or inside a part? Second, did you press Play? Scripts only run while the game is running. Third, read the Output window — a red error names the exact line and the problem. Fourth, check your capitals and brackets — Luau cares about both, and a missing end is the most common beginner bug.

Can I get banned for scripting in Roblox Studio?

No. Scripting inside Roblox Studio is the official, encouraged way to create games. Bans come from using cheat programs — called script executors — inside other people’s games, or from downloading “free script” tools from shady websites. Build and test your own scripts in Studio, and you are doing exactly what Roblox is for.

Try These Next

Once your first scripts work, the next step is a real game. Our Grow a Garden codes page shows what a finished Roblox game looks like from the player’s side — and the codes there are the official ones, checked weekly. The Blox Fruits codes page is the same idea for the biggest Roblox fighting game: official codes, a redeem guide, and a full expired list so you can tell what still works. Play a few games, notice what their scripts do, and then come back and build your own version.

↓ Click the Stars to Rate This Recipe ↓

Tried this recipe? Leave a review!

Consider leaving a 5 star rating if you’ve made and loved one of my recipes!

Related Posts

Scroll to Top