Add a Question
Add a Question
Store Info Inside the Variable
What’s stored inside of variables can be changed by using the =
symbol. A variable might change many times inside of a script or as the program runs.
- After the variable name, like
local name1
, type=
while playing do storyMaker:Reset()   -- Code story between the dashes -- =============================================   local name1 =
The next step will be to ask the players a question and store their answer inside of the variable.
- After
=
, typestoryMaker:GetInput("Question")
. 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("Question")
storyMaker:GetInput()
Scripts can talk to each other. This game has a second script named storyMaker
, and inside of that is code for getting player input. The variable just made will run the code from the storyMaker
script and then store the player’s answer.
String Types
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"
.
- Replace
"Question"
with what you want to ask players in order to complete the next line of the story. Don’t forget to include the quotation marks (""
).
while playing do storyMaker:Reset()   -- Code story between the dashes -- =============================================   local name1 = storyMaker:GetInput("What is your favorite name?")
Previous Asking Questions Next Testing Your Code