Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the script skipping variables?

Asked by
Komas19 34
1 year ago

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
0
The question marks on the messages variable are emojis, but are not displaying correctly for some reason. Komas19 34 — 1y

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
1 year ago
Edited 1 year ago

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)
0
still skips to message6, but this time message1 doesn't load (also no errors in output Komas19 34 — 1y
0
Recoded, See if this works MattVSNNL 620 — 1y
0
Try adding a cooldown, since while wait() do does a loop instantly ryanzhzh 128 — 1y
0
now nothing is happening, not even in the output Komas19 34 — 1y
View all comments (4 more)
0
Sorry typo MattVSNNL 620 — 1y
0
still doing nothing Komas19 34 — 1y
0
message1 is not even showing Komas19 34 — 1y
0
I don't know anymore sorry MattVSNNL 620 — 1y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

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

Answer this question