[HOW DO I] How do I make a game based on choices that plays a storyline?

I want to do something else since I am quite bored and I wanna know the logic behind these games.

For example, this game story is based on what decision you choose:

Like I wanna know what structure of coding are behind these games and other similar mechanics/gameplay it possess.

3 Likes

A lot of animations to be made, and a tree-like structure based on ModuleScripts and connections. Effects such as sounds or animations are within the ModuleScript.

4 Likes

Although ive never made story games, what i would do is make a main script, this scipt will then send signals to other scripts through remote events when you choose an option and the story will go in that direction, then when the diversion is finished, the sub script will send a remote event signal to the main script to continue through the main lines of the story

1 Like

Could you provide me an example for clearer view?

These kinds of games are heavily scripted, requiring a team or a lot of persistence spanning a long while.

One method not highlighted by others and easier to understand based on choices can be seen in SHADOW THE HEDGEHOG (2006) which uses a linear progression system moving the player down different storylines based on which goal(s) they achieved in the level. This method of choice-based narrative requires less data saving directly, just linear teleportation and sequencing (can be achieved with ROBLOX’s Universes System).

The method you’ve shown - choices communicated through interaction (or lack thereof) - requires the data-saving method extensively throughout the duration of the game world. Others have communicated using modulescripts and remote events as the player progresses. You have to have more planning with this route and need a stable, organized means of structuring the player save data so that you can easily find the choices the player made at certain intervals or in chapters/levels. An example format:

-- Data Table
local PlayerData = {
 -- Game Chapters as sub-tables
 Chapter1 = {
  InteractedWithNPCA = false,
  InteractedWithNPCB = false
 },

 Chapter2 = {
  CompletedNPCATask = false,
  CompletedNPCBTask = true
 }
}

-- Side note here: The InteractedWithNPCB and CompletedNPCB task contradiction is intentional.
-- It could be useful doing a dual-check in the event a player *can* complete a goal or meet a condition without ever meeting the starting conditions, if that's a part of your game design.

return playerData

It’s likely this would be used by NPCs or triggers to check you meet conditions before allowing you to go forward in the storyline or to the next area in the level/world. These are also fairly closely related to Questing Systems, which is something that you should look at further than just the following example (especially look at how other games handle quests under the hood).

I do go on a tangent about this so fair warning beforehand.

Questing System Tangent

My favourite example of a questing system is how Bethesda handles quest data in Creation Engine titles through a Dual-ID system - Form ID and Editor ID. An Example Quest from one of those games being “Following in His Footsteps” - a Main Quest in Fallout 3.

A positive to this system is that it’s easy to check which quests the player currently has unlocked and which one(s) they’re progressing with. This’d be done via storing a table in player save data for the Quest IDs they’ve unlocked, storing a table for which one’s focused and the two sets of Quest Co-ordinates for the Map HUD and World Location.

Representative Table for “Following in His Footsteps”

local Quest = {
	-- The key for the table being the hexadecimal "Form ID" above.
	["00014E87"] = {
		EditorID = "MQ01",
		-- Main Quest 01
		-- fun fact: it's actually the fifth main quest but it's likely the ID was assigned based on it being the first designed/intended quest.

		
		QuestName = "Following In His Footsteps",
		-- Quest Name for displaying on the User Interface
		
		QuestSteps = {},
		-- The list of steps, quest step lines (e.g. New Objective) and Conditions to:
		--    A) Complete Quest
		--    B) Move to Next Quest Step
		--    C) If the player Fail the Quest Step
		--    D) Next Quest Location (map co-ordinates for in-world map [Vector3] (and/or Map UI [UDim2])
		
		CurrentQuestLocation = Vector3.zero,
		
		CurrentStepConditions = {} 
		-- Whatever Conditions the player needs to meet. 
		-- Maybe a function that you call on which checks specific values of the player inventory or save file?
		-- May also have other functions to check if the player has prevented progression.
	}
}

return Quest

This post likely will also need corrections. If you notice anything I missed feel free to reply to this or send a PM about it.

3 Likes

Well heres an example:

main script: Ok we are at a point now where the player has to make a decision between choice 1 and choice 2.

player: picks option 2

main scipt: looks like the player picked option 2, i gotta activate the script that is related to it

remote event: Alright the main script told me to activate the script related to option 2

Option 2 script: Looks like remote event is telling me to activate myself, here we go

option 2 script: alright im done let me tell main script to turn on to continue with the main lines of the story

Remote event: Okay chill ill tell main script to carry on seesh i do so much work here

Main script: well looks like option 2 stuff is finished lets carry on with the story!! :slight_smile:
Hope that helps

Just a heads up, this method itself would be unlikely in practice.

A Script would not need to use a RemoteEvent to activate a ModuleScript. It just needs to Require the ModuleScript and call a relevant function that initializes (or runs through all sequencing of) the option consequence.

That’s a well thought-out explanation

Do you think this applies to this one as well?

You can check out the game, it’s similar to the Detroit : Become Human whereas the player should decide something right to proceed to storyline, otherwise failure would be met.

It applies.

Look towards external game engines which have way better community support, toolkits (plugins, tutorials, etc) and much better performance than ROBLOX does. There are dialog trees, node systems and many tools you can use in ROBLOX to make the process faster but it likely won’t be the same as using an engine that has been built from the ground up with these systems in mind from the get-go.

You can probably find tutorials done in Unity and Unreal for the systems you want to learn. With experience in those engines, Contextualized C#/C++ alongside Lua and understanding the gameplay systems you want to translate over, you may have a better experience at understanding and disassembling the steps and mechanics to reproduce them in several engines.


Contextualized C#/C++ → C#/C++ applied within their respective game engines.

Alr so, listen im not such a experienced dev, im pretty young, but the way I see it, you would need a ton of module scripts, and a TON of elseif statements. So if you want to go exactly like TWD then you would want a lobby menu with a ton of different places to act as episodes, then in those episodes, you need tons of animations and audios, as well as cutscenes, or you can use one of those cutscene plugins to make it easier. Then you also would need guis for buttons, and here is where the module scripts come in. You would need to write several events and there elseif statements so for example you have two choices, “move foward” or “stay here”, you would choose either one to write a line on so you could say the player clicks move foward and the coresponding events, but if they choose stay here, you could use a elseif statement and write the other coresponding events, and basically you would need to write the script in a very ordered fashion, this would result in possibly around 3-4k lines in the script, and also what I would say is if you want different endings is at the conclusion of the chapter, to make it simple make it so the final 2, 3, 4 whatever choices have different events intertwined with them, and those lead to the conclusion. If you also want to save the endings for the next episodes, use datastores and you could also use a ton of elseif statements, but that would result in probably like a 1k or possibly a 5k line script. Ye ik this is like coming a year later from the begining of the disccusion and idk if you already found the answer, but I think this super long response could help!

You can always go the Undertale route and make thousands of if-else statements ¯\_(ツ)_/¯.

ye lol i mean theres obviously a better way to make it more shorter but yk im not that experienced yet yk still learnin