How would I make a tutorial GUI

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

Well I deleted my scripts and am re-writing them.

1 Like

So my script that is supposed to change the text is here:

TextTable = {"Welcome to Vaccine Simulator!","Buy and sell vaccines to save the world","blah blah 3"}
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)

and my script that opens the tutorial is here:

script.Parent.MouseButton1Down:Connect(function()

	script.Parent.Parent.TutorialFrame.TutorialText.Text = "Hello, welcome to Vaccine Simulator!"
	script.Parent.Parent.TutorialFrame.Visible = true
end)

Everything is working but now I am still stuck at the point that when I close it then re-open it its still at the last frame. I cannot make it so TutorialStep = 1 in another script because they are two different scripts and only one defines TutorialStep.

1 Like

And I might just make it all in the same script if this cannot work.

1 Like

I would honestly just make it all into one script. It would take like 30 seconds to combine them, and it would solve a bunch of your issues.

1 Like

Alright, when I am done I will reply what the result is, happy scripting!

2 Likes

I am a bit confused (Because I am a rookie scripter) On what to do :confused:
edit: I think I figured it out

1 Like

Is something wrong here?

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

TextTable = {"Welcome to Vaccine Simulator!","Buy and sell vaccines to save the world","blah blah 3"}
TutorialStep = 1
script.Parent.Parent.TutorialText.Text = TextTable[TutorialStep]
script.Parent.Parent.TutorialFrame.Next.MouseButton1Click:Connect(function()
TutorialStep = TutorialStep + 1
    script.Parent.Parent.TutorialText.Text = TextTable[TutorialStep]
end)

edit: No errors
edit2: Fixed, Happy scripting :smiley:

3 Likes