Write a Lua Script to Print Your Name

Write a simple Lua script that prints your name on the screen, learning basic coding ideas like strings, the print function, and running code.

Game Development10 min12 steps
Start buildingMore tutorials
Write a Lua Script to Print Your Name
Write a Lua Script to Print Your Name
10 minVibe coding
12 steps โ†’

About this tutorial

Write a simple Lua script that prints your name on the screen, learning basic coding ideas like strings, the print function, and running code.

What you need

๐ŸงฐOnline Lua editor (like repl.it or lua.org demo)๐ŸงฐBasic typing skills

Step by step

  1. 1

    Step 1

    Open your web browser and go to an online Lua editor like repl.it or the Lua.org demo.

  2. 2

    Step 2

    Start a new Lua file or project in the editor.

  3. 3

    Step 3

    Click inside the code area so the cursor is ready to type.

  4. 4

    Step 4

    Type print("Your Name") and replace Your Name with the name you want the program to show.

  5. 5

    Step 5

    Save the file or give your project a name if the editor asks.

  6. 6

    Step 6

    Press the Run button in the editor to run your Lua script.

  7. 7

    Step 7

    Look at the output area and read the name your program printed.

  8. 8

    Step 8

    Change the text inside the quotes to a nickname or a different name.

  9. 9

    Step 9

    Press Run again to see the new name appear on the screen.

  10. 10

    Step 10

    Add a second line and type print("Hi! I'm Your Name") to make a friendly greeting.

  11. 11

    Step 11

    Run your program one more time to see both lines print.

  12. 12

    Step 12

    Share your finished Lua script and a screenshot or description of what it prints on DIY.org

Fun facts

๐ŸŒ™Lua means "moon" in Portuguese โ€” the language was created in Brazil!
๐Ÿง‘โ€๐Ÿ’ปLua is tiny and fast: its core is only a few kilobytes, so itโ€™s great for embedding in games and apps.
๐Ÿ“The classic first program is "Hello, world!" โ€” printing your name is the same fun first step.
๐ŸŽฎPopular games and platforms like Roblox and World of Warcraft use Lua for scripting behaviors.
๐Ÿ”คIn Lua you can write strings with single or double quotes, e.g., print('Your Name') or print("Your Name").
๐ŸŒ™Lua means "moon" in Portuguese โ€” the language was created in Brazil!
๐Ÿง‘โ€๐Ÿ’ปLua is tiny and fast: its core is only a few kilobytes, so itโ€™s great for embedding in games and apps.
๐Ÿ“The classic first program is "Hello, world!" โ€” printing your name is the same fun first step.
๐ŸŽฎPopular games and platforms like Roblox and World of Warcraft use Lua for scripting behaviors.
๐Ÿ”คIn Lua you can write strings with single or double quotes, e.g., print('Your Name') or print("Your Name").

How do you write a Lua script to print your name?

To write a Lua script that prints your name, open a text editor and type: print("Your Name"). Save the file as myname.lua. Run it with a Lua interpreter on your computer (lua myname.lua) or paste into an online Lua sandbox. Explain that text inside quotes is a string and print shows output. Try changing the text and running again to see how code changes produce different results.

Go deeper

What materials do I need to write a Lua name-printing script?

You need a computer, tablet, or Chromebook with a simple text editor (Notepad, TextEdit, or code editor) and a Lua interpreter or access to an online Lua editor. A keyboard helps typing, though touchscreens and coding apps work too. Optional items: a parent or teacher for guidance, and an internet connection if you use web-based sandboxes. No special hardware is required for this basic activity.

Go deeper

What ages is writing a Lua print script suitable for?

This activity suits children aged about 7โ€“14. Ages 7โ€“9 can try it with adult help to type, save, and run the script. Ages 10โ€“12 often work independently and enjoy experimenting with changes. Teens can extend the task by adding variables or multiple print statements. Adjust support for each childโ€™s reading and typing skills and pair younger kids with a grown-up for guidance.

Go deeper

What are the benefits and safe variations of this Lua activity?

Benefits include learning strings, the print function, and how code runs, boosting logic and confidence. Safety tips: supervise internet use and be careful installing software; use online sandboxes or offline interpreters you trust. Variations: print multiple lines, store the name in a variable (local name = "Alex"; print(name)), or make a simple greeting that asks for input. These extensions encourage creativity and problem-solving.

Go deeper

Watch & Learn

Need help?

What can we use if we can't access repl.it or the Lua.org demo?

If you can't access repl.it or the Lua.org demo, install the Lua interpreter and run your file with the lua command or use another online IDE that supports Lua, then create a file, type print("Your Name"), save, and Run.

Why does my program show an error or nothing when I press Run?

If you get an error or no output after pressing Run, make sure you typed print("Your Name") with straight quotes and parentheses, selected Lua as the language in the editor, saved the file if the editor needs it, and checked the output/console area.

How can we adapt this activity for different ages?

For younger children, have an adult type and press Run while the child picks names, and for older kids, replace the hard-coded name with a variable and io.read() or add the second line print("Hi! I'm "..name) to practice input and string concatenation.

What's a fun way to extend or personalize the script before uploading a screenshot to DIY.org?

Personalize it by changing the text inside the quotes to a nickname, adding the second line print("Hi! I'm Your Name"), or modify the script to ask for a name with io.read() and then print a custom greeting so the output makes a neat screenshot for DIY.org.

Your first game is on us.

Describe a game below - no sign-up needed to try.

Make me

Kids GPT is now ChatDino

Kid-safe AI for discovery and learning.

Open ChatDino

Powered by AstroSafe

3,127Devs Online
1,284Games Made
1,415,800Total Plays

Make real games - not just chat

DIY.org

Kid-safe AI for discovery and learning. Ask anything, explore everything, learn with confidence.

Product

  • Pricing
  • App
  • All Apps

Resources

  • Blog
  • Kids Wikipedia
  • Worksheets
  • Activities for Kids
  • Build a Hacker Simulator
  • SafeTube

Company

  • About
  • Terms & Conditions
  • Privacy Policy
  • AstroSafe
TwitterInstagramYouTube

ยฉ 2026 DIY.org. All rights reserved. ยท Powered by AstroSafe