Best Way to Store Dialogue/A lot of Text?

I’m assuming this would go in the scripting support category but please inform me if not.

What would be the best way to store dialogue for say, a conversation with an NPC or a tutorial GUI with multiple screens? The idea would be for a player to be able to go backwards and forwards through the different tutorial stages if necessary. Hope this makes sense haha

Well, you could use StringValues and make a folder, put it inside each of the NPC and put the values inside that folder, so whenever you wanna make the NPC say a certain text, you can refer to that folder and maybe use iteration.

Well, I personally think storing all the Dialogue in a Module would work great. And if you store it as a Table within that module, you can go back and forth through the table by increasing or decreasing the Index. Of course you’d also have to organize it with the different events and possible dialogues.

1 Like

I think that might work… although how do you access modules from other scripts? Or should I save your time and look it up

Sorry for the late response, but you’d have to require() them.

A better example would be like this : require(game.ReplicatedStorage.Module)

There is also many resources you can use to learn to better use Modules.

There are many ways to do this.

The Top 2 ways are the following:

EVENTS/REMOTES:
Use an OnClient event and make a remote function doing this for you. The script contains all the dirty code (The code that in a way would flood a regular script) and just fire it every time.

MODULE SCRIPTS:
Use a module script to repeat this function every time.

Just to clarify, require() would return a table/dictionary with all the contents of the module?

Yes, and I do recommend the module method too, as it allows for any organization that you really want.

local Dialog = {
    Tutorial = {
        "This is the first piece of text shown to the player.",
        "This is the second.",
        "Continue adding entries here"
    },
    SomethingElse = {
        -- ...
    }
    -- ...
}

return Dialog