My script don't work

Hello!
In the past week i worked on my new game and i made a tutorial for the players and the script is don’t work.

So my goal is to create a tutorial gui. Here is the localscript:

And its not working and i don’t know why.

Here is the error:
https://gyazo.com/5c2441f26774a456281dc9d8ba6b4f7c

So the error is it stuck in the second text and don’t change the text.
No errors in the output.

(btw i’m not a scripter)

I appreciate all the replies!

I don’t know if it has anything to do with this, but it seems in the script you are doing

tutorial.Visible = true -- Set visibility to true

if tutorial.Visible == true then -- Check if visibility is true
   -- Do stuff
end

You are setting the visibility to true and then checking if it is true, so the if loop will always be executed because you had just set the visibility to true.

The other possible problem (which is much more likely) is that creating a new event on the button when it moved to the next part of the tutorial doesn’t override the previous event created. That means that every time you press the button, it restarts the tutorial to the first part of the tutorial.

I hope that makes sense, let me know if this helps. :slight_smile:

You’re encasing a whole lot of nested functions, which all of them will individually work whenever they’re supposed to which isn’t exactly the best use case

You should implement a better sanity check to see what current message there is, maybe something like this could do:

local frame = script.Parent
local no = frame.No
local yes = frame.TextButton
local tutorial = frame.Parent.Tutorial
local skip = tutorial.TextButton

local CurrentText = script.Parent.Text --We can save this as a current variable, then change it to whatever text we wanna detect

no.MouseButton1Click:Connect(function()
    frame.Visible = false
end)

yes.MouseButton1Click:Connect(function()
    frame.Visible = false
    
    if tutorial.Visible == true then
        wait(3)
        skip.BackgroundTransparency = 0
    end
end)

skip.MouseButton1Click:Connect(function()
    if CurrentText == "Insert current text here" then
        --Do something
    elseif CurrentText == "Insert next current text here" then
        --Do another thing
    end
end)

Ok, you are trying to add MouseButton1Click events inside of each other. You are making this much more complicated than this needs to be. Just use a variable like local Current = 0, add to that each time they click, and check what its on.

local Current = 0

yes.MouseButton1Click:Connect(function()
    frame.Visible = true
    tutorial.Visible = true
    if tutorial.Visible == true then
        skip.MouseButton1Click:Connect(function()
            Current += 1
            if Current == 1 then
                --1st click
            elseif Current == 2 then
                --2nd click
            elseif Current == 3 then
                --3rd click
            elseif Current == 4 then
                --4th click
            end
        end)
    end
end)
1 Like

Thank you! It solved it! :blush: