Write a Lua Script to Print Your Name
Green highlight

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

Orange shooting star
Download Guide
Collect Badge
Background blob
Challenge Image
Skill Badge
Table of contents

Step-by-step guide to write a Lua script to print your name

What you need
Basic typing skills, online lua editor (like repl.it or lua.org demo)

Step 1

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

Step 2

Start a new Lua file or project in the editor.

Step 3

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

Step 4

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

Step 5

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

Step 6

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

Step 7

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

Step 8

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

Step 9

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

Step 10

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

Step 11

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

Step 12

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

Final steps

You're almost there! Complete all the steps, bring your creation to life, post it, and conquer the challenge!

Complete & Share
Challenge badge placeholder
Challenge badge

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.

Watch videos on how to write a Lua script to print your name

Here at SafeTube, we're on a mission to create a safer and more delightful internet. 😊

Writing Letter 'e' in English | Phonics Sounds | How to write the letter 'e' for kids

4 Videos

Facts about programming basics for kids

🔤 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!

🎮 Popular games and platforms like Roblox and World of Warcraft use Lua for scripting behaviors.

📝 The classic first program is "Hello, world!" — printing your name is the same fun first step.

🧑‍💻 Lua is tiny and fast: its core is only a few kilobytes, so it’s great for embedding in games and apps.

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.

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.

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.

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.
DIY Yeti Character
Join Frame
Flying Text Box

One subscription, many ways to play and learn.

Try for free

Only $6.99 after trial. No credit card required

Write a Lua Script to Print Your Name. Activities for Kids.