Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

How Kids Can Build a First Roblox Game: Six Beginner Luau Scripts

Start a first Roblox Studio project with six short Luau scripts that teach messages, variables, conditionals, functions, touch events, and a disappearing platform.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Kids can start a Roblox game in Roblox Studio by making a small place, adding a server Script, and learning one behavior at a time. The examples below move from a visible message to conditions, functions, touch events, and a disappearing platform. Roblox scripting uses Luau, a language derived from Lua 5.1; “Lua scripts” is a common search phrase, but Luau is the language used in Studio.

What you need before writing a Roblox script

Roblox describes Studio as a free application for Windows or Mac. Create a Roblox account, install Studio, and open a new place. In Studio, the Explorer shows the place’s object hierarchy: parts make up physical objects, while scripts add behavior. The kind and location of a script affect where it runs.

As an Amazon Associate I earn from qualifying purchases.

These examples use regular Script objects placed in ServerScriptService, which Roblox uses in its first-script tutorial. A Script runs on the server; a LocalScript runs on the client, and a ModuleScript can be required by server or client scripts. Put the code in the stated location rather than placing every script wherever convenient.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add a script, find ServerScriptService in Explorer, insert a Script, and edit it in the Script Editor. Open the Output window, then use Studio’s Play control to run the place. The editor also provides autocomplete, syntax highlighting, static linting, type checking, and script analysis; use its diagnostics to spot code issues and Output to see runtime messages.

#1 Best Overall
Roblox Physical Gift Card
  • Redemption: Online only. Robux cards can only be redeemed in a browser at Roblox.com/redeem. They cannot be redeemed in the Roblox mobile app or any video game console.
  • Roblox is an immersive platform for connection and communication. Every day, millions of people come to Roblox to create, play, work, learn, and connect with each other in experiences built by our global community of creators.
  • Get more with every Roblox Gift Card! From now on, when you redeem a Roblox gift card, you get up to 25% more Robux. Perfect for gaming, creating, and exploring- more Robux means more possibilities!
  • Deck out your avatar and unlock additional perks in your favorite experiences when you use Roblox Gift Cards to purchase Robux (Roblox's virtual currency).
  • Each gift card grants a free virtual item upon redemption.

Roblox’s official learning path covers variables and objects, functions and events, conditionals, loops, tables, and organized code. These six examples are a starter sequence, not a replacement for the full curriculum. Change one value at a time and playtest after each change.

1. Print a message when the game starts

Where it goes

In Explorer, select ServerScriptService and insert a Script. Name it HelloGame.

Code

print("Hello, game!")

What to notice and change

Press Play and look in Output for Hello, game!. This confirms the script ran. Change the text inside the quotation marks and play again. print() sends a message to Output; it does not display text to players in the game world.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Roblox Digital Gift Card - 1,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
  • The easiest way to add Robux (Roblox’s digital currency) to your account. Use Robux to deck out your avatar and unlock additional perks in your favorite Roblox experiences.
  • This is a digital gift card that can only be redeemed for Robux at Roblox.com/redeem. It cannot be redeemed in the Roblox mobile app or any video game console. Please allow up to 5 minutes for your balance to be updated after redeeming.
  • Roblox Gift Cards can be redeemed worldwide, perfect for gifting to Roblox fans anywhere in the world.
  • From now on, when you redeem a Roblox Gift Card, you get up to 25% more Robux. Perfect for gaming, creating, and exploring- more Robux means more possibilities!
  • Every Roblox Gift Card grants a free virtual item upon redemption.

2. Store a message in a variable

Where it goes

Keep this as a separate Script in ServerScriptService; name it WelcomeMessage.

Code

local message = "Welcome to my game!"
print(message)

What to notice and change

When you play, Output shows the value stored in message. The word local makes this variable available in its local scope, rather than making it a global variable. Change the text, or try a number instead: set message to 3 and see what Output prints.

3. Make a decision with an if statement

Where it goes

Add another Script to ServerScriptService and name it ChooseMessage.

Rank #3
Roblox Digital Gift Card - 2,500 Robux [Includes Exclusive Virtual Item] [Digital Code]
  • The easiest way to add Robux (Roblox’s digital currency) to your account. Use Robux to deck out your avatar and unlock additional perks in your favorite Roblox experiences.
  • This is a digital gift card that can only be redeemed for Robux at Roblox.com/redeem. It cannot be redeemed in the Roblox mobile app or any video game console. Please allow up to 5 minutes for your balance to be updated after redeeming.
  • Roblox Gift Cards can be redeemed worldwide, perfect for gifting to Roblox fans anywhere in the world.
  • From now on, when you redeem a Roblox Gift Card, you get up to 25% more Robux. Perfect for gaming, creating, and exploring- more Robux means more possibilities!
  • Every Roblox Gift Card grants a free virtual item upon redemption.

Code

local coins = 5

if coins >= 5 then
    print("You have enough coins!")
else
    print("Collect more coins.")
end

What to notice and change

With coins set to 5, Output shows the first message. An if statement checks a condition; else supplies the alternative when that condition is false. Change coins to 2 and play again to see the other result. This example only prints a message; it does not create or save in-game coins.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Reuse an action with a function

Where it goes

Create a separate Script in ServerScriptService named SayWelcome.

Code

local function sayWelcome()
    print("Welcome to the adventure!")
end

sayWelcome()

What to notice and change

The function holds an action, and sayWelcome() calls it. Run the place and check Output. Then call the function a second time on a new line to make the message appear twice. Functions become especially useful when connected to events, so the action runs in response to something that happens.

Rank #4
Roblox Digital Gift Card - 2,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
  • The easiest way to add Robux (Roblox’s digital currency) to your account. Use Robux to deck out your avatar and unlock additional perks in your favorite Roblox experiences.
  • This is a digital gift card that can only be redeemed for Robux at Roblox.com/redeem. It cannot be redeemed in the Roblox mobile app or any video game console. Please allow up to 5 minutes for your balance to be updated after redeeming.
  • Roblox Gift Cards can be redeemed worldwide, perfect for gifting to Roblox fans anywhere in the world.
  • From now on, when you redeem a Roblox Gift Card, you get up to 25% more Robux. Perfect for gaming, creating, and exploring- more Robux means more possibilities!
  • Every Roblox Gift Card grants a free virtual item upon redemption.

5. React when something touches a part

Where it goes

In Explorer, add a Part to Workspace. Keep it anchored so it stays in place, and give it a name such as WelcomePad. Insert a Script inside that part.

Code

local part = script.Parent

local function onTouched(otherPart)
    print("Something touched the pad!")
end

part.Touched:Connect(onTouched)

What to notice and change

Press Play and move your character into the part. The Touched event fires when something touches the part, and Connect() attaches the function that responds. Check Output for the message. Change the message, or change the part’s Color in Properties and then set its color from inside onTouched to make the reaction visible. A touch can produce multiple event calls as different character parts make contact.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Make a platform disappear when touched

Where it goes

Add a second anchored Part to Workspace, name it VanishingPlatform, and place it where the character can reach it. Insert a Script inside the part.

Best Value
Roblox Digital Gift Card - 5,250 Robux [Includes Exclusive Virtual Item] [Digital Code]
  • The easiest way to add Robux (Roblox’s digital currency) to your account. Use Robux to deck out your avatar and unlock additional perks in your favorite Roblox experiences.
  • This is a digital gift card that can only be redeemed for Robux at Roblox.com/redeem. It cannot be redeemed in the Roblox mobile app or any video game console. Please allow up to 5 minutes for your balance to be updated after redeeming.
  • Roblox Gift Cards can be redeemed worldwide, perfect for gifting to Roblox fans anywhere in the world.
  • From now on, when you redeem a Roblox Gift Card, you get up to 25% more Robux. Perfect for gaming, creating, and exploring- more Robux means more possibilities!
  • Every Roblox Gift Card grants a free virtual item upon redemption.

Code

local platform = script.Parent
local disappearing = false

local function onTouched(otherPart)
    if disappearing then
        return
    end

    disappearing = true
    platform.Transparency = 1
    platform.CanCollide = false
end

platform.Touched:Connect(onTouched)

What to notice and change

Touching the platform makes it transparent and turns off collision, so the character can pass through it. The disappearing variable prevents the function from running its change repeatedly after the first touch. Try changing Transparency to 0.5 for a partly visible platform. This version does not make the platform return; a timed reset would need additional logic.

Why these scripts run in different ways

The first four scripts run when the server starts the script during a playtest. The last two connect a function to a part’s touch event, so the function runs when that event occurs. Events are a common way to respond to gameplay without repeatedly checking for the same condition in a loop.

The visible results also differ: print() writes to Output for the creator, while changing a part’s properties affects the game world. Parts expose properties such as Transparency and CanCollide, which scripts can change to create simple gameplay effects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to troubleshoot a beginner script

  • Nothing appears in Output: Confirm the script is a Script in ServerScriptService and that you pressed Play. Open Output and check for runtime messages.
  • The editor marks a line: Check spelling, quotation marks, parentheses, and the end statements for functions and conditionals. Read the Script Editor’s diagnostics.
  • The touch script does not react: Make sure the script is inside the part you intend to use, and that the character can reach the part during Play mode.
  • The platform still blocks the character: Verify the code sets CanCollide to false and that you are touching the same part that contains the script.

Roblox’s Luau documentation explains the language used in Studio. Its scripting introduction covers local variables and Roblox scripting, while the create-a-script tutorial walks through script placement and Output. For the concepts behind the examples, see Coding fundamentals, Events, the Data model, and the Introduction to scripting. To continue from a first place into broader projects, use Roblox’s Core curriculum.

Quick Recap

Bestseller No. 1
Roblox Physical Gift Card
Roblox Physical Gift Card
Each gift card grants a free virtual item upon redemption.; Physical gift cards are delivered active via mail.
$50.00
Bestseller No. 2
Roblox Digital Gift Card - 1,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
Roblox Digital Gift Card - 1,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
Every Roblox Gift Card grants a free virtual item upon redemption.; For more information, please visit roblox.com/giftcardFAQs.
$10.00
Bestseller No. 3
Roblox Digital Gift Card - 2,500 Robux [Includes Exclusive Virtual Item] [Digital Code]
Roblox Digital Gift Card - 2,500 Robux [Includes Exclusive Virtual Item] [Digital Code]
Every Roblox Gift Card grants a free virtual item upon redemption.; For more information, please visit roblox.com/giftcardFAQs.
$25.00
Bestseller No. 4
Roblox Digital Gift Card - 2,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
Roblox Digital Gift Card - 2,000 Robux [Includes Exclusive Virtual Item] [Digital Code]
Every Roblox Gift Card grants a free virtual item upon redemption.; For more information, please visit roblox.com/giftcardFAQs.
$20.00
Bestseller No. 5
Roblox Digital Gift Card - 5,250 Robux [Includes Exclusive Virtual Item] [Digital Code]
Roblox Digital Gift Card - 5,250 Robux [Includes Exclusive Virtual Item] [Digital Code]
Every Roblox Gift Card grants a free virtual item upon redemption.; For more information, please visit roblox.com/giftcardFAQs.
$50.00

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.