Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is the script skipping variables?

ok so, i have this script, and, it goes from message1 to message6 instantly, it should be message1, message2, message3, message4, message5, message6

LocalScript :

local place = game:GetService("Players").LocalPlayer.IsTutorialFinished
local textplace = script.Parent.Text
local button = script.Parent.OK.MouseButton1Click
local sound = script.Parent["OK.last"].ding
local button1 = script.Parent["OK.last"]
local button2 = script.Parent.OK.Visible
local message1 = "Welcome to "..game.Name.." ! This is the tutorial which will help you to play the game! Press Ok to continue, press X to not read it."

local message2 = "Touch a PC to pick it up! Then press OK to continue."

local message3 = "After that, you can press the???? button at the top left! After that, press OK to continue."

local message4 = "Now, you can go to the SELL building, or you can click the ???? Sell button at the top left! Then touch the building, then press OK to continue."

local message5 = "Press the ?????????? button at the top left to upgrade your pc space! Then click 'Upgrade to maximum possible pc space with that amount of money', and that will make you have more pc space! Press OK to continue."

local message6 = "Thats pretty much it, you can press the ???? button at the top left to have more stuff. Gamepasses are permanent and one time use only, products are temporary and can use it an infinite amount of time. Press finish to finish the tutorial."

while wait() do
	if place.Value == false then
		button:Connect(function()
			sound:Play()
			if textplace.Text == "Loading" then
				textplace.Text = message1
			end
			if textplace.Text == message1 then
				textplace.Text = message2
			end
			if textplace.Text == message2 then
				textplace.Text = message3
			end
			if textplace.Text == message3 then
				textplace.Text = message4
			end
			if textplace.Text == message4 then
				textplace.Text = message5
			end
			if textplace.Text == message5 then
				textplace.Text = message6
				button1.Visible = true
				button2 = false
				button1.Text = "finish"
				button1.MouseButton1Click:Connect(function()
					script.Parent.Visible = false
				end)
			end
		end)
	end
end

1 comment

0

The question marks on the messages variable are emojis, but are not displaying correctly for some reason.

2 answers

This should work!

local place = game:GetService("Players").LocalPlayer.IsTutorialFinished
local textplace = script.Parent.Text
local button = script.Parent.OK.MouseButton1Click
local sound = script.Parent["OK.last"].ding
local button1 = script.Parent["OK.last"]
local button2 = script.Parent.OK.Visible

local messages = {
	[1] = "Welcome to "..game.Name.." ! This is the tutorial which will help you to play the game! Press Ok to continue, press X to not read it.";
	[2] = "Touch a PC to pick it up! Then press OK to continue.";
	[3] = "After that, you can press the???? button at the top left! After that, press OK to continue.";
	[4] = "Now, you can go to the SELL building, or you can click the ???? Sell button at the top left! Then touch the building, then press OK to continue.";
	[5] = "Press the ?????????? button at the top left to upgrade your pc space! Then click 'Upgrade to maximum possible pc space with that amount of money', and that will make you have more pc space! Press OK to continue.";
	[6] = "Thats pretty much it, you can press the ???? button at the top left to have more stuff. Gamepasses are permanent and one time use only, products are temporary and can use it an infinite amount of time. Press finish to finish the tutorial.";
}

local currentLine = 1

place:GetPropertyChangedSignal("Value"):Connect(function()
	if place.Value == true then
		
		button.MouseButton1Click:Connect(function()
			sound:Play()

			for messageLine, message in pairs(messages) do
				if messageLine == currentLine then

					currentLine += 1
					
					local length = string.len(message)
					
					for i = 1, length do
						textplace.Text = message:sub(1, i)
						wait(0.06)
					end
					
					if messageLine == 6 then
						
						button1.Visible = true
						button2 = false
						button1.Text = "finish"
						button1.MouseButton1Click:Connect(function()
							script.Parent.Visible = false
						end)
						
					end

				end
			end

		end)
		
	end
end)

8 comments

0

still skips to message6, but this time message1 doesn't load (also no errors in output

0

Recoded, See if this works

0

Try adding a cooldown, since while wait() do does a loop instantly

0

now nothing is happening, not even in the output

0

Sorry typo

0

still doing nothing

0

message1 is not even showing

0

I don't know anymore sorry

hey you! have you ever heard of enes? if you are in trouble, better call enes!

This discussion is preserved as it was. New answers, comments, and votes are closed.