How would I make a tutorial GUI

How would I make a tutorial gui that has next/back?

if I said
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Text = Text1
end)
How would I make it so it moves the text to Text2 when I click ‘Next’?

1 Like

You can create a table of different strings, and then grab one of those strings in accordance to the tutorial slide you are on.

For example:

TextTable = {"blah blah 1","blah blah 2","blah blah 3"}
TutorialStep = 1
script.Parent.Text = TextTable[TutorialStep]
script.Parent.MouseButton1Click:Connect(function()
TutorialStep = TutorialStep + 1
    script.Parent.Text = TextTable[TutorialStep]
end)

There are many methods to accomplishing this, but this is a great way to go about it, because you can keep all your messages all in one compact table.

2 Likes

Hello, I just have one more issue. When I close it then re-open it up it will not let me press next because its still on the last frame. How do I make it so when I close it and then re-open it the text says blah blah 1?

Edit: If you want video to explain it more please ask me

1 Like

You just need to reset TutorialStep to 1, then reset the TextLabel’s “Text”.

--run this when you re-open your GUI
TutorialStep = 1
script.Parent.Text = TextTable[TutorialStep]
1 Like

But the thing that makes it change text and the thing that opens the GUI are in different scripts.
Screen Shot 2020-07-14 at 2.00.52 pm

1 Like

What should I do about this?
(30 char)

1 Like

You have a few options here. You could either, combine them scripts into one, or just set the text in your TextLabel manually from the GUI open script, like so:

-- run this from the GUI open script
script.Parent.Parent.Next.Text = "blah blah 1"
1 Like

Like so? (Open script)

script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.TutorialFrame.TutorialText.Text = "Hello, welcome to Vaccine Simulator!"
	script.Parent.Parent.TutorialFrame.Visible = true
end)
1 Like

Something is wrong:


Why cant I press next after I have closed it?

1 Like

Based on the genealogy you showed me, you would need to use script.Parent.Parent.Next.TutorialNext.Text, instead of script.Parent.Parent.TutorialFrame.TutorialText.Text to access the Text inside TutorialText.

1 Like

My issue here is: How would I access the variable ‘tutorialstep’ from another script?

1 Like

For instance:
Saying TutorialStep = 1 In another script wouldn’t work because it will not recognise the variable.

1 Like

You could define TutorialStep as a Global variable. What is _G and for what i can use it? - #6 by jaschutte

1 Like

I tried that so I put this is the next script

_G.TutorialStep = 1

and now nothing works. I cannot even change the text. So in the 2nd script I put:
–under the open script
_G.TutorialStep = 1

1 Like

Are you editing he contents of the variable through _G? You need to also prefix TutorialStep by _G. even after it is defined.

1 Like

Here are the two scripts:
open script:

script.Parent.MouseButton1Down:Connect(function()

_G.TutorialStep = 1

script.Parent.Parent.TutorialFrame.TutorialText.Text = "Hello, welcome to Vaccine Simulator!"

script.Parent.Parent.TutorialFrame.Visible = true

end)

next script:

TextTable = {"Buy vaccines then sell them to get money and stop the virus","Depending on the virus, it afffects how bad the infections are","Then, use your money to buy more, and better vaccines.","Make sure to like, favourite and share this game with your friends! Good luck on saving the earth."}
_G.TutorialStep = 1
script.Parent.Parent.TutorialText.Text = TextTable[TutorialStep]
script.Parent.MouseButton1Click:Connect(function()
TutorialStep = TutorialStep + 1
    script.Parent.Parent.TutorialText.Text = TextTable[TutorialStep]
end)
1 Like

Is there anything wrong with these scripts? If not, why are they not working?

1 Like

Make sure to access TutorialStep from _G the second time, as well as the first.

_G.TutorialStep = _G.TutorialStep + 1
1 Like

So I put this is the first script, second or both?

edit: I put it in both now absolutely nothing works

1 Like

Any errors? Can I see your code now?

1 Like