What Is a Roblox Script?
A Roblox script is a small program written in Luau (Roblox's flavor of Lua) that tells your game what to do. Scripts handle everything dynamic: when a player joins, what happens when they touch a part, how damage works, what the shop UI displays, when DataStore saves progress.
If you can build a 3D world in Roblox Studio, you can build a beautiful diorama — but it won't be a game until you add scripts. This tutorial covers how to make a Roblox script from absolute zero, with three working examples and the shortcuts experienced developers use to skip the tedious parts.
The Three Types of Roblox Scripts
Before you write anything, you need to know which type of script to use. There are three:
- Script (server): Runs on Roblox's servers. Use for anything that affects all players or needs to be secure — DataStore, damage, game pass checks, round logic.
- LocalScript (client): Runs on the individual player's device. Use for UI, camera control, input handling, and client-side visual effects.
- ModuleScript: A reusable library. It doesn't run on its own — other scripts
require()it to use shared functions or data.
Rule of thumb: if a malicious player could exploit it (giving themselves coins, skipping pay walls, doing fake damage), put it in a server Script. Never trust the client.
Step 1: Open Roblox Studio and Create a New Place
- Download Roblox Studio from
create.roblox.comif you haven't already (it's free) - Click New > Baseplate to create an empty world
- You'll see a flat gray platform — your blank canvas
Step 2: Find the Explorer and ServerScriptService
The Explorer panel (right side of Studio — open from the View tab if hidden) shows everything in your game as a tree. The folder you'll use most for server scripts is called ServerScriptService.
To add a new script:
- Right-click ServerScriptService in the Explorer
- Click Insert Object > Script
- Double-click the new Script to open the code editor
This is the basic answer to "how to put scripts in Roblox" — you parent them to the right service depending on whether they should run on the server or client.
Step 3: Write Your First Roblox Script
Delete whatever default text is in the editor and paste this:
print("Hello, Roblox!")
Now hit the Play button at the top of Studio. Look at the Output panel (View tab > Output). You should see:
Hello, Roblox!
Congratulations — you just made and ran your first Roblox script.
Step 4: A Useful First Script — Welcome Players by Name
"Hello, Roblox!" isn't very exciting. Let's make a script that does something real. Replace your code with this:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " just joined the game!")
end)
Hit Play. As your test character spawns, the Output window prints YourName just joined the game!
What's happening here:
game:GetService("Players")grabs the Players service, which tracks everyone in the gamePlayers.PlayerAddedis a signal that fires whenever a new player joins:Connect(function(player) ... end)attaches a function that runs when the signal fires, with the new player passed in
Step 5: A Working Kill Brick — Roblox's "Hello World" of Game Scripting
Almost every Roblox tutorial includes a kill brick because it teaches the most useful pattern in Roblox scripting: reacting when a part is touched.
- In the Explorer, click Workspace
- Add a Part to the world (Home tab > Part > Block) — place it in the air a bit so players will run into it
- Color it red (Properties > BrickColor > Really red) so it looks dangerous
- Right-click the part > Insert Object > Script
- Paste this into the script:
local part = script.Parent
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)
Hit Play, walk your character into the red brick, and watch it die. You just built a working kill brick from scratch. This is the most reused pattern in Roblox — touched detection, humanoid lookup, applying an effect.
Step 6: A LocalScript Example — Press F to Open a Menu
For UI and input, you write a LocalScript instead. Right-click StarterPlayer > StarterPlayerScripts in the Explorer, Insert Object > LocalScript, and paste:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
print("Player pressed F!")
end
end)
Run the game and press F. The Output prints "Player pressed F!" each time. Replace the print with code that opens a UI panel and you have a working menu hotkey.
Common Beginner Mistakes (and How to Fix Them)
- Putting server logic in a LocalScript. Players can edit local scripts. Anything affecting other players or game state belongs in a server Script.
- Forgetting to anchor parts. A part that should sit still falls into the void if it isn't anchored. Check Properties > Anchored.
- Using
wait(). The oldwait()function is deprecated. Usetask.wait()instead. - No
pcallaround DataStore. DataStore calls can fail. Always wrap them:local ok, err = pcall(function() ... end). - Looking for nil children. Use
:FindFirstChild("Name")instead of.Namewhen the child might not exist.
Where to Get Roblox Scripts If You Don't Want to Write Them
If you'd rather not learn Luau from scratch, you have three options:
- Use an AI Roblox script generator. Tools like Obby let you describe what you want in plain English and produce working Luau. This is by far the fastest path in 2026.
- Copy from the Creator Hub.
create.roblox.com/docshas hundreds of working code samples with explanations. - Use the Roblox Studio Assistant. Built into Studio, free, generates Luau from prompts.
One important note: there are sites that distribute "free Roblox scripts" labeled as exploits or cheats. Don't use them. They violate Roblox's terms of service and almost always contain malicious code that compromises your account.
From Scripts to a Full Game
Knowing how to make Roblox scripts is essential, but stringing together dozens of scripts to make a complete game is where most projects stall. Obby generates entire game systems — combat, DataStore, GUIs, game passes — wired together correctly from one prompt. Start there to skip the scaffolding and focus on what makes your game unique.


