Skip to content

How to Script on Roblox

A beginner guide to your first Luau script in Roblox Studio, with a generator to try each step.

Updated · 8 min read
On this page

Roblox games are programmed in Luau, a language based on Lua. You don’t need to know any code yet. By the end of this guide you’ll have a script that changes your world when a character touches something.

What you need

  • Roblox Studio, available on Windows and Mac.
  • A Roblox account to sign in to Studio.
  • About 20 minutes and a new place to experiment.

Open Studio and make a Baseplate

  1. Open Roblox Studio and sign in.
  2. Create a new place using the Baseplate template.
  3. Open the Explorer and Output windows. Explorer shows your objects; Output shows messages and errors.

Your first Script

In Explorer, add a Script inside ServerScriptService. Replace its contents with this:

FirstScript.server.lua
-- Your first scriptprint("Hello from my game!")local part = workspace.Baseplatepart.BrickColor = BrickColor.new("Bright green")

Press Play. The message appears in Output and the Baseplate turns green. Stop the test before editing again: changes made during a playtest may not persist.

Script vs LocalScript

TypeRuns onUse it for
ScriptThe server, with default settingsShared game rules: doors, kill bricks, leaderboards
LocalScriptOne player’s deviceMenus, buttons, camera effects
ModuleScriptWherever it is requiredReusable functions and configuration
Rule of thumbIf only one player should see an interface or camera effect, start with a LocalScript. Keep rewards and shared game rules on the server.

Make something happen

Add an anchored Part to Workspace, name it KillBrick, and put a new Script inside that Part. This example resets any character with a Humanoid that touches it, including NPCs:

KillBrick.server.lua
-- Put this Script inside an anchored Partlocal brick = script.Parentbrick.Touched:Connect(function(hit)    local character = hit.Parent    local humanoid = character:FindFirstChildOfClass("Humanoid")    if humanoid then        humanoid.Health = 0    endend)

brick.Touched:Connect(function(hit)
1Runs when another part touches the brick.
FindFirstChildOfClass("Humanoid")
2Looks for a Humanoid in the touching part’s parent.
humanoid.Health = 0
3Sets the character’s health to zero after the check.

Keep CanTouch enabled on the brick, then walk into it in Play mode. These are learning examples; test them in your own place before publishing.

Next steps

Build your next small idea.

Try the generator