Story Game Project

Introduction

In the Story Game Project, words are going missing and it’s up to you to fill in the blanks!

Writing the Story

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 and
the name of friends are one, two, three, four, five, six, seven, eight, nine and ten.

Creating Placeholders

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.

  1. In the first sentence, pick a single word to be replaced by the player such as a name, action, or a noun.

  2. Replace the word with a placeholder for what type of word you’ll ask the player for.

  3. 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!

Open the Template

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.

Close Extra Windows

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.

  1. 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.

  2. Leave the Explorer window on the right side open. Make Studio look like the image below.

Opening the Script

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 StoryManager Script

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

Comments

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.

Asking Questions

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.

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.

1.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.

2. After =, type storyMaker: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?")

Write the Story

Code the First String

  1. Make sure the playtest is stopped.

  2. Go back to the script by clicking on the StoryManager script tab above the game editor.

  3. Beneath where you typed the question, create a new variable named story. Make sure the variable name is lowercase.

  4. 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.

  5. Have the 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 "

Last updated