Working on Strings?

I’m trying to advance myself further with Strings - I’m attempting to use the Wiki however I’m finding it far easier // better for my learning to engage in conversation and query stuff rather than sitting and reading.

What I’m looking at doing:
As the player progresses through the game; their “Story” value is increased by +1; However, my ModuleScripts for the cutscenes are labelled as: “#0_Introduction”’ “#1_Waking up”;

I was wondering how I could use Strings to find the corresponding Module for the StoryValue?

I would probably just put the cutscene labels into a list like this:

cutscenes = {"#0_Introduction", "#1_Waking up"}

Then you can just get the cutscene like this!


Now depending on whether your story value starts at zero you will have to mess with it, but that should work for you!

1 Like

It does work at 0^^
I understand your point though!

I’ve been looking at String.Find hoping that could be implemented in a way.

Personally I think it would be easier to do it the way I showed you. Is there any reason why you want to use all the string stuff?

If you’re really set on using string manipulation for this, you can use a combination of string.find to determine whether the number exists within the # and _, and if so return the module. I don’t think this is optimal, but it’s probably the easiest way to do it with strings.

Edit: made the information more correct

Think I’ve figured it:

	for _,i in pairs (ReplicatedStorage["Storyline"]:GetChildren()) do
		local str = i.Name
		if str:find("#" .. PlayerData["isStory"].Value .. "_") then
1 Like