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)
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)
Something is wrong:
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.
My issue here is: How would I access the variable ‘tutorialstep’ from another script?
For instance:
Saying TutorialStep = 1 In another script wouldn’t work because it will not recognise the variable.
You could define TutorialStep as a Global variable. What is _G and for what i can use it? - #6 by jaschutte
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
Are you editing he contents of the variable through _G? You need to also prefix TutorialStep by _G. even after it is defined.
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)
Is there anything wrong with these scripts? If not, why are they not working?
Make sure to access TutorialStep from _G the second time, as well as the first.
_G.TutorialStep = _G.TutorialStep + 1
So I put this is the first script, second or both?
edit: I put it in both now absolutely nothing works
Any errors? Can I see your code now?
Well I deleted my scripts and am re-writing them.
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.
And I might just make it all in the same script if this cannot work.
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.
Alright, when I am done I will reply what the result is, happy scripting!
I am a bit confused (Because I am a rookie scripter) On what to do
edit: I think I figured it out
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