Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Code a question
Remember how you wrote a sentence for your story, then swapped a word out for a placeholder? It's time to give players a chance to add something to your game.
In the script, the placeholder you made will be a variable. In coding, variables are placeholders for information, in this case a word.
You'll start by asking players a question. Then, they'll type in an answer that gets stored in the variable.
Create a variable
Variables have names that tell programmers what they store. In this case, you'll create a variable called name1 for the placeholder.
Click below the dashed lines and type
local name1.-- 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 -- ============================================= local name1 -- ============================================= -- Add the story variable between the parenthesis below storyMaker:Write() -- Play again? playing = storyMaker:PlayAgain() end
Set a variable
Now players need to have a chance to put something inside the placeholder. To change a variable, it needs to be set to something using the = symbol.
After
name1, make sure to add a space and then type=.while playing do storyMaker:Reset() -- Code story between the dashes -- ============================================= local name1 = -- ============================================= -- Add the story variable between the parenthesis below storyMaker:Write() endAfter the equal sign, type
storyMaker:GetInput(). The code must be typed exactly as is, and capital letters must match.while playing do storyMaker:Reset() -- Code story between the dashes -- ============================================= local name1 = storyMaker:GetInput() -- ============================================= -- Add the story variable between the parenthesis below storyMaker:Write() end
Type a question
Variables can store different types of data including small numbers, true or false values, and strings. String type variables are special because they can store whole sentences. It's easy to spot string type variables because they're always in quotation marks "like this".
The question to ask players will be a string variable.
In
GetInput(), click between the parentheses. Inside type a question enclosed by quotation marks.-- Code story between the dashes -- ============================================= local name1 = storyMaker:GetInput("What is your favorite name?") -- ============================================= end