In the Story Game Project, words are going missing and it’s up to you to fill in the blanks!
Before coding, write the story you’ll use as the base of your game. The story can be about anything you wish. Write 2-3 sentences for the opening paragraph.
Once upon a time, there was a Wise Wizz of Woo. He had magical friends andthe name of friends are one, two, three, four, five, six, seven, eight, nine and ten.
To create a word game out of the story, delete words from the story and create placeholders for them. In the game, players will answer questions to fill in the placeholders. Start with just the first sentence.
In the first sentence, pick a single word to be replaced by the player such as a name, action, or a noun.
Replace the word with a placeholder for what type of word you’ll ask the player for.
Since you might end up asking the player for more than one noun or adjective, number the placeholder.
The story is now ready to turn into code!
Templates are pre-made worlds that you can use as a base for your own games.
Download the template.
In Roblox Studio, in the top left, click File > Open from File and select the downloaded file.
The first time you launch Roblox Studio, extra windows might open up that you don’t need right now. Closing the extra windows will give you more space to see what you’re doing.
Close all windows on the left side of Studio by clicking the ×. If you don’t see anything to close, go to the next step.
Leave the Explorer window on the right side open. Make Studio look like the image below.
In Roblox, code is typed inside of scripts using the coding language Lua. Games often have separate scripts for each thing the game needs to do. The library template already has a script named StoryManager which you’ll add more code to for your word game.
To find the StoryManager script:
In the Explorer window, click the arrow next to StarterGUI to see everything beneath it.
Click the arrow next to GameGUI to expand that section.
Double-click the StoryManager script to open it.
The script already contains some of the code that’s necessary for showing the completed story to the player. All of the code you create will be typed below the dashed lines.
--Special achnowledgement @polarpanda16.-- GLOBAL VARIABLESlocal storyMaker = require(script:WaitForChild("StoryMaker"))-- Code controlling the gamelocal playing = truewhile playing dostoryMaker:Reset()-- Code story between the dashes-- =============================================-- =============================================-- Add the story variable between the parenthesis belowstoryMaker:Write()-- Play again?playing = storyMaker:PlayAgain()end
Lines of code starting with
-- are comments. Comments are used to leave notes for yourself and other coders. They don’t change the way the program runs.
The variable you just created will be used to both ask players questions and to store their answer. The questions will show up in the middle of the player’s screen after they click on the large book at the front of the library.
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.
1.After the variable name, like
local name1, type
while playing dostoryMaker: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.
storyMaker:GetInput("Question"). The code must be typed exactly as is, and capital letters must match.
while playing dostoryMaker:Reset()-- Code story between the dashes-- =============================================local name1 = storyMaker:GetInput("Question")
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.
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
"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 dostoryMaker:Reset()-- Code story between the dashes-- =============================================local name1 = storyMaker:GetInput("What is your favorite name?")
Make sure the playtest is stopped.
Go back to the script by clicking on the StoryManager script tab above the game editor.
Beneath where you typed the question, create a new variable named
story. Make sure the variable name is lowercase.
To find the first string, go back to the original story. Circle or highlight everything before the first placeholder. If your variable happens to be in the middle of a sentence, no problem - the rest can be added later.
story variable store the string like below:
local name1 = storyMaker:GetInput("What is your favorite name?")local story = "In a tree on a hill lives the great wizard "