This commit is contained in:
Joe 2026-02-02 12:08:47 -06:00
parent a9b4f8e83b
commit e6efc04756
8494 changed files with 495610 additions and 0 deletions

View file

@ -0,0 +1,113 @@
---
title: Customize strings
description: Explains how to customize the strings for your story.
next: /tutorials/curriculums/coding/next-steps
prev: /tutorials/curriculums/coding/test-and-save
---
With the first sentence of your story done and working in Studio, it's time to customize your string with punctuation and line breaks. Once you are happy with how it looks and reads to players, you can add more sentences and finish the rest of your story.
## Add punctuation
When you playtest your experience, your first sentence doesn't include any punctuation to let players know the sentence is complete. To fix this, you can add another string using the same process of concatenation to connect your words with your punctuation.
To add punctuation:
1. On the same line as the **story** variable, type two periods.
1. Add another string with a punctuation mark, such as a period or exclamation point, then an extra space so your next sentence doesn't start immediately after the punctuation mark.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! ")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
## Add line breaks
A line break moves the cursor to the next line of text. This is helpful when you want every sentence to start from the left-side of the page, and enhance your story's readability in the giant book.
To add a line break:
1. On the same line as the **story** variable, type `\n`.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! \n")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
1. <Chip label="OPTIONAL" size="small" variant="outlined" /> You can add more than one line break by adding as many `\n` as you need. For example, the following code sample adds in three line breaks.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! \n\n\n")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
## Add more sentences
Now that your first sentence includes punctation and any applicable line breaks, you can add more sentences to your story and ask players more questions for your placeholder words.
To add more sentences:
1. Under your first variable, create a new variable for your second placeholder and ask a question related to what type of placeholder word it is. For example:
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local food1
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! \n\n\n")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
1. Using the same process as your first variable, set the variable and use the provided `storyMaker:GetInput()` method that displays your questions in the giant book. For example:
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local food1 = storyMaker:GetInput("What do you like to eat?")
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! \n\n\n")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
1. Combine the first string of the story with the player's answer using `..`.
1. On the same line as the **story** variable, add two periods.
1. Add a space, then type the name of the variable that stores the player's second answer.
1. Add two more periods, then finish the sentence with a punctuation mark.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local food1 = storyMaker:GetInput("What do you like to eat?")
local story = ("In a tree on a hill lives the great wizard " .. name1 .. "! \n\n\n" .. "Every morning, the wizard loves eating a giant bowl of honey roasted " .. food1 .. ". ")
-- =============================================
-- =============================================
storyMaker:Write(story)
```
1. Repeat this process for your entire story, then playtest your experience using the steps from the previous chapter to make sure your code works properly.

View file

@ -0,0 +1,65 @@
---
title: Get started
description: Explains how to get started with opening a project.
next: /tutorials/curriculums/coding/work-with-variables
prev: /tutorials/curriculums/coding/
---
Welcome to your first beginner coding lesson in Studio! To get started, let's walk through how to open the sample template, customize Studio's layout for your tasks, and brainstorm the core gameplay's story that you will code throughout the tutorial.
## Open template
Templates are pre-made 3D worlds that you can use as the base for your own experiences. To introduce you to coding in Studio, Roblox has created the **Story Game** template with everything necessary for the experience to work properly, except for the code for your story.
<img src="../../../assets/tutorials/coding-lesson/StoryGameThumb.png" width="70%" />
<Alert severity="info">
For a full list of Roblox-provided templates, see [Templates](../../../resources/templates.md).
</Alert>
Click the following button to open the **Story Games** template:
<UseStudioButton variant="" buttonTextTranslationKey="Action.EditInStudio" placeId="118424838654294" universeId="7930204318" />
## Customize workspace
Roblox Studio launches with extra windows open that you don't need for this lesson. You can close these extra windows to create more space for what you're currently working on.
To customize the workspace for your coding task:
1. Close each window on the **left** of the 3D view by clicking the **&times;** in the window's upper-right corner. If you don't see anything to close on the left, go to the next step.
2. Leave the **Explorer** and **Properties** windows open on the right side of Studio. If you have done each step correctly, Studio looks like the following image.
<img src="../../../assets/education/general/Studio-Setup-Story-Games.jpg" width="960" />
<Alert severity="warning">
If you don't see the **Explorer** and **Properties** windows, open them from Studio's **Window** menu.
</Alert>
## Brainstorm your story
Before you start coding, it's important to take a moment and write a story for your core gameplay where players can replace placeholder words with their own answers. The story can be silly, scary, mysterious, or about anything you want. Here are a few story ideas:
- Your dream vacation
- A superhero's shopping trip
- What a wizard eats for breakfast
The more details you include, the more options you have for placeholder words in your game. The sky is the limit, so have a good time!
To brainstorm your story:
1. Using a piece of paper or a text editor on your computer, write 2-3 sentences for the opening paragraph.
1. In the first sentence, pick a single word that you want your players to replace, such as a noun, action, or character's name. For example:
_In a tree on a hill lives the great wizard **Nia**._
1. Replace that word with a placeholder for what type of word that you are going to ask the player for, such as thing, action, or name. Because you likely are going to ask the player for more than one noun or adjective, it's recommended to number the placeholder, such as thing1, action1, or name1.
_In a tree on a hill lives the great wizard **name1**._
1. Repeat this process for every sentence of your story.
_In a tree on a hill lives the great wizard **name1**. Every morning, the wizard loves eating a giant bowl of honey roasted **food1**. Unless it's a Saturday, then the wizard likes to go to a local restaurant called **building1** with their dear friend **name2**. They always order at least one **food2**, of course!_
Now that you have a story, it's time to turn it into code!

View file

@ -0,0 +1,88 @@
---
title: Intro to coding
description: Learn the basics of coding for experiences.
next: /tutorials/curriculums/coding/get-started
hideInPageNavigation: true
---
<>
<Grid
alignItems="stretch"
container
direction="row">
<Grid item Large={7} XSmall={12} direction="column">
<img src="../../../assets/tutorials/landing/CodingThumbnail.png" width="90%" />
</Grid>
<Grid item Large={5} XSmall={12} direction="column">
Using the [Story Games](https://www.roblox.com/games/2546610365/Roblox-Creator-Challenge) sample as a guide, this tutorial acts as an introduction to coding in Roblox Studio using the Luau programming language. As you follow each chapter, you will learn how to create a story game where players can replace placeholder words with their own answers.
This lesson is intended for readers who are **brand new** to coding concepts and working in Studio. If you are familiar with both, try another beginner lesson plan or jump straight to [building your first experience](../core/index.md).
</Grid>
</Grid>
</>
<Alert severity = 'info'>
If you don't have a Roblox account, Studio active on your device, or familiarity with Studio's UI, see the [Studio lesson](../studio/index.md).
</Alert>
## Course contents
<BaseAccordion>
<AccordionSummary>
<Typography variant="h4">Chapter 1 - Get started</Typography>
</AccordionSummary>
<AccordionDetails>
Learn how to [open and customize](get-started.md) the template's workspace so that you can work with your main script.
</AccordionDetails>
</BaseAccordion>
<BaseAccordion>
<AccordionSummary>
<Typography variant="h4">Chapter 2 - Work with variables</Typography>
</AccordionSummary>
<AccordionDetails>
Learn how to [use variables](work-with-variables.md) to ask players questions and use their answers within your story.
</AccordionDetails>
</BaseAccordion>
<BaseAccordion>
<AccordionSummary>
<Typography variant="h4">Chapter 3 - Test and save</Typography>
</AccordionSummary>
<AccordionDetails>
Learn how to [playtest your story](test-and-save.md) and publish your work to Roblox.
</AccordionDetails>
</BaseAccordion>
<BaseAccordion>
<AccordionSummary>
<Typography variant="h4">Chapter 4 - Customize strings</Typography>
</AccordionSummary>
<AccordionDetails>
Learn how to [style your code](customize-strings.md) with extra punctuation and line breaks.
</AccordionDetails>
</BaseAccordion>
<BaseAccordion>
<AccordionSummary>
<Typography variant="h4">Chapter 5 - Next steps</Typography>
</AccordionSummary>
<AccordionDetails>
Learn where you can [find more tutorials](next-steps.md) about coding for experiences.
</AccordionDetails>
</BaseAccordion>

View file

@ -0,0 +1,40 @@
---
title: Next steps
description: Explains ways to continue learning about coding in Studio.
next: /tutorials/curriculums/artist/
prev: /tutorials/curriculums/coding/customize-strings
---
Congratulations on completing your first code sample with Roblox Studio! Now that you have experience working with variables, you can share your work with others and extend your skills by learning about Studio's additional coding features.
## Share with others
When you first publish an experience, it's automatically set to **private** so that you are the only one who can play it. However, creating on Roblox is always more fun when you can share what you make with others, so let's set up your experience so that they can play too.
To make your experience public:
1. Using the steps from the **Test and save** chapter, publish your experience so others can see your latest changes.
1. In the top-left corner of your computer, click **File** ⟩ **Experience Settings**.
1. In the settings window:
1. Go to the left bar and select the **Permissions** tab. New settings display.
1. Set **Playability** to **Public**.
1. Click the **Save** button. Now everyone on Roblox can play your experience!
## Continue learning
Variables are an excellent start in your coding journey, but Luau includes additional fundamentals that are important to understand to add custom behavior to your experiences, including:
- [Script types and locations](../../../scripting/locations.md)
- [Services](../../../scripting/services.md)
- [Properties and attributes](../../../scripting/attributes.md)
- [Events](../../../scripting/events/index.md)
It's recommended to continue learning with the [Coding fundamentals](../../fundamentals/coding-1/coding-fundamentals.md) series, then if you want to continue learning through step-by-step lessons, check out the following use case tutorials:
- [Create deadly lava](../../use-case-tutorials/scripting/basic-scripting/deadly-lava.md)
- [Create fading traps](../../use-case-tutorials/scripting/basic-scripting/fading-trap.md)
- [Create health pickups](../../use-case-tutorials/scripting/intermediate-scripting/create-a-health-pickup.md)
- [Save player data](../../use-case-tutorials/scripting/intermediate-scripting/save-data.md)

View file

@ -0,0 +1,102 @@
---
title: Test and save
description: Explains how to playtest and save your story experience.
next: /tutorials/curriculums/coding/customize-strings
prev: /tutorials/curriculums/coding/work-with-variables
---
Now that the first sentence of your main story is complete and ready for players to write their own answer for the playerholder word, it's time to playtest your experience to verify that the code runs properly, then publish your work to Roblox so that you can save your progress.
## Playtest your code
It's important to playtest your experience often to ensure that your code works as expected. Studio offers several playtest options:
- **Test** – Starts the playtest by inserting your avatar at a spawn location.
- **Test Here** – Starts the playtest by inserting your avatar in front of the camera's current position.
- **Run** – Starts the playtest without inserting your avatar. Instead, the playtest begins at the current camera position and you can navigate around using the camera controls.
While all options are useful at different times, it's important to use a playtest option that inserts your avatar so that you can access the book and play through your story.
To playtest your code:
1. In the top-left corner of Studio, verify that your playtest is set to either **Test** or **Test Here**, then click the **Play** button. Studio enters playtest mode.
<img src="../../../assets/education/general/play-button.png" width="360" />
1. In the experience, use the following player controls to walk up to the pedestal, then press <kbd>E</kbd> to open the book and start your story. Your first question should display if the code is working properly.
<table>
<thead>
<tr>
<th>**Action**</th>
<th>**Control**</th>
</tr>
</thead>
<tbody>
<tr>
<td>**Move**</td>
<td><kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> or arrow keys</td>
</tr>
<tr>
<td>**Rotate**</td>
<td>Hold the right mouse button and look around.</td>
</tr>
<tr>
<td>**Pan**</td>
<td>Hold the middle mouse button to drag your camera around.</td>
</tr>
</tbody>
</table>
<img src="../../../assets/education/story-games/StoryExample.png" width="70%" />
1. Answer the question and click the **Submit** button.
<img src="../../../assets/education/story-games/wcc2018_annotatedStory.png" />
1. When you're done, return to the top-left corner of Studio, then click the **Stop** button. Studio exits playtest mode.
<img src="../../../assets/education/general/stop-button.png" width="360" />
If your first sentence didn't show up, check out the following troubleshooting tips:
**Issue**: The book doesn't display your first question.
Check that the question is inside of quotation marks.
**Issue**: The story is combined.
Check the following:
- The first part of the story is inside of quotation marks.
- The name of the variable holding the player answers matches exactly. Capitalization counts!
- The name of the variable holding the player's answer is not inside of quotation marks.
- The two strings are separated by `..`.
**Issue**: The book doesn't display the first sentence of your story.
Check the `storyMaker:Write()` function to make sure the **story** variable is in between the parentesis.
## Publish to Roblox
If you were to close Studio now, you would lose every edit you made to your experience. For this reason, it's important to publish your work to Roblox often to save your work and connect the experience to your account.
<Alert severity="info">
It's recommended to publish to Roblox every ten minutes or after making a big change.
</Alert>
1. In the top-left corner of your computer, click **File** ⟩ **Publish to Roblox** to open the publishing window.
1. In the **Publish Game** window,
1. In the **Name** field, provide a name for your experience.
1. <Chip label="OPTIONAL" size="small" variant="outlined" /> In the **Description** field, provide a summary of what a player can expect from the experience.
1. In the **Devices** section, enable every device you want players to use to access your experience.
1. At the bottom-right of the window, click the **Create** button.
Now that your experience is published and connected to your account, you can edit it from any computer!
<Alert severity="info">
<AlertTitle>Saving after publishing</AlertTitle>
Next time you want to save your work, just go to **File** ⟩ **Publish to Roblox** or use the hotkey combo (<kbd>Alt</kbd><kbd>P</kbd>/<kbd>⌥</kbd><kbd>P</kbd>).
</Alert>

View file

@ -0,0 +1,140 @@
---
title: Work with variables
description: Explains how to work with variables to create a story experience.
next: /tutorials/curriculums/coding/test-and-save
prev: /tutorials/curriculums/coding/get-started
---
In coding, **variables** are placeholder words for different types of information in your experience, such as player names, a team's score, or words for a story game. In this chapter, let's explore how to open the main script for the core gameplay of the experience and add code to ask players questions and use their answers for your story.
## Open script
Roblox creators write their code inside of **scripts** that tell Studio how and when to add custom behavior to experiences, such as triggering different types of events, saving player information, or spawning enemies. Roblox scripts use the [Luau](https://luau.org) programming language, which you can learn more about later in the [Coding fundamentals](../../fundamentals/coding-1/) series.
The Story Game template uses a single script named **StoryManager** to control the core gameplay of the experience. This script already contains some code that's necessary for showing the full story to the player, but you will add more to display your interactive story.
To open the **StoryManager** script:
1. In the **Explorer** window, click the arrow next to **StarterGui** to see everything it contains. **GameGui** displays.
1. Click the arrow next to **GameGui** to see everything it contains. The **StoryManager** script displays at the top along with a few other things that aren't important for this lesson.
<img src="../../../assets/education/story-games/StoryManager.png" width="40%" />
1. Double-click the **StoryManager** script. The script's code displays.
```lua
-- GLOBAL VARIABLES
local storyMaker = require(script:WaitForChild("StoryMaker"))
-- Code controlling the game
local playing = true
while playing do
storyMaker:Reset()
-- Code story between the dashes
-- =============================================
-- =============================================
-- Add the story variable between the parenthesis below
storyMaker:Write()
-- Play again?
playing = storyMaker:PlayAgain()
end
```
Notice how a large portion of the code uses the `--` symbol, which is called a **comment**. Coders use comments to leave notes, and they don't change the way the script runs. For this lesson, you are going to create your code between the dashed line comments so that you can focus on creating your interactive story in one spot.
## Ask players questions
As a best practice, coders create variables with names that describe the type of information they store. For example, if you were working on a game where players are split into teams:
- The `team` variable stores information about the player's **team**.
- The `teamColor` variable stores information about the player's **team color**.
- The `teamScore` variable stores information for the player's **team score**.
Variables can store all sorts of information, such as small numbers, true or false answers, and strings. String type variables are special because they can store whole sentences, including the questions that you want to ask your players.
Using your placeholder words from the previous chapter, you can create string type variables with the same placeholder names that describe what type of word that you are going to ask the player for as they play your story game.
To create variables for your player questions:
1. Click below the dashed line comments and create a local variable for the first word you want players to replace with their own answer. For example:
```lua
-- =============================================
local name1
-- =============================================
```
1. Set the variable using the `=` symbol to the provided `storyMaker:GetInput()` method that displays your questions in the giant book. You must type this method exactly as it is with its specific capitalization in order for the code to work. For example:
```lua
-- =============================================
local name1 = storyMaker:GetInput()
-- =============================================
```
1. Create a string in between the parenthesis with the question you want to ask your players. Remember, strings are always in quotation marks!
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
-- =============================================
```
## Use their answers
Now that you have a question that players can answer, it's time to code your story and add behavior that replaces your placeholder word with their answer.
To create variables for your story and to use player answers:
1. Under your question, create a new variable named story. Remember, variables are lowercase!
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story
-- =============================================
```
1. Set your string type variable to the first sentence of your story before your first placeholder, leaving a space after the last word and before the quotation mark. If your placeholder word happens to be in the middle of a sentence, you can add the rest of the sentence in a later chapter of the tutorial.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard ")
-- =============================================
```
1. Combine the first string of the story with the player's answer using `..`. Combining things together is called **concatenation**.
1. On the same line as the **story** variable, add two periods.
1. Add a space, then type the name of the variable that stores the player's first answer.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard " .. name1)
-- =============================================
```
1. Show this first part of the story to players by calling the story variable from the provided `storyMaker:Write()` method that writes your story in the giant book.
```lua
-- =============================================
local name1 = storyMaker:GetInput("What is your favorite name?")
local story = ("In a tree on a hill lives the great wizard " .. name1)
-- =============================================
-- =============================================
storyMaker:Write(story)
```
Now's a good point to stop momentarily, playtest the experience in the next chapter, and make sure the story is working!