How do I make a Gui only able to be pressed once

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make a button that can be pressed only once

  2. What is the issue? I have gotten it to work but when the character dies the button reappears.

  3. What solutions have you tried so far? I have tried looking on youtube and on the devforum.
    My code so far:

local TextButton = script.Parent
local Frame = script.Parent.Parent.Frame
TextButton.MouseButton1Down:Connect(function()
TextButton.Visible = false
Frame.Visible = true
end)

Why I need the button. I need it so that I can allow users to select their class once AND ONLY ONCE.
If you can help ASAP that would be appreciated tremendously. Thank you for your time reading this and your possible support.

Just simply add a variable that’ll check if the Button has been pressed, so that the Gui can’t be pressed again

local Enabled = false
local TextButton = script.Parent
local Frame = script.Parent.Parent.Frame

TextButton.MouseButton1Down:Connect(function()
    if Enabled == false then
        Enabled = true

        TextButton.Visible = false
        Frame.Visible = true
    end
end)

I will try that out thank you for replying so quickly this is my first time using the dev forum so I didn’t know if it would work.

Not to worry, it’s completely fine :sweat_smile: Everyone comes here whenever they struggle with a specific issue

Lemme know what happens btw :slightly_smiling_face:

1 Like

Unfortunately it didn’t work I retried it multiple times.

You need to set the ScreenGui.ResetOnSpawn to disabled

RobloxStudioBeta_2019-06-09_12-15-56
(random image of it found on google)

1 Like

Usually you find it within your Properties tab if you have that visible, if you don’t I believe you should find it in the top bar:

View > Properties

1 Like

Thanks all of you guys for helping me out.

Wait a minute it isn’t working.

@TheLazyRaven @JackscarIitt Sorry for bothering you again but IDK why it isn’t working.

Hm, could you give us a breakdown on what’s exactly happening from your side?

When you click the Button, does the Frame show up? And if you reset, will it show the Button again?

When I click the button the Frame shows up but when I die/reset so does the button.

Could we see your properties on what your ScreenGui shows? A screenshot would be handy to view it

Another potential guess is that maybe the Gui is being cloned (Which could be a script intercepting that perhaps?)

I think the Gui is being cloned… I remember a yt named thedevking warning me about that he said if you wanted to do what I am doing do it from the rep storage. Idk if this helps lemme see if I can get that pic.

@JackscarIitt here is the pic.

As you can see the ResetOnSpawn is off.

Appreciate it :slightly_smiling_face:

Is there anywhere in your Explorer that there’s a script that’s cloning that ScreenGui and parenting it to your own PlayerGui/StarterGui?

There are 3 other scripts that I worked on so far. A bow, an arrow, and the Gui script above.

Would you like to see the bow and arrow scripts?