Making a choose your adventure game with multiple endings

  1. What do you want to achieve? I want to make a game where you choose what happens to the characters.

  2. What is the issue? I am looking for an effective/working way to store input

  3. What solutions have you tried so far? Storing the input in a module script

Thanks for reading :slight_smile:

5 Likes

If you’re trying to do something like the walking dead, What you could do is store the paths as numbers,

For decision 1 you add 1, decision 2 you remove 2. These numbers will eventually lead to certain outcomes.

2 Likes

So if the remaining result is 45 then:
ending 3

Would I store the number in a ModuleScript

Exactly, and you don’t need to store it in a modulescript, What i would advise by structure is the following:

Make a script, Name it something like “Control” or “Handler” then have modulescripts in it, Each called Ending 1, 2 , 3 etc then you want to store this value in the handler script.

Lastly, when it is time to chose the ending, As oppose to requiring every single module script, You can require it at the end by corresponding each value number to an ending like this:

local ValueToEndingNum = {
[25] = 1,
[15] = 2,
[45] = 3,
}

This way, you can index the module script like this: require(script["Ending "…ValueToEndingNum[Value]])

So what you’re ultimately doing is: Value is 45 for example, Corresponding in the table to ending 3.

Then you construct a string and require the module based off that string.

1 Like