ScreenGUI Problem

I want to make a button, and when a player clicks it, it disables GUI “ResetOnSpawn” for him/her.

I have tried this script but it did not work.

script.Parent.MouseButton1Click:Connect(function()

script.Parent.Parent.Parent.ResetOnSpawn = false

end)

1 Like

is that a serverscript or local?

1 Like
script.Parent.Parent.Parent.ResetOnSpawn = false

You are redefining the whole GUI. Use GUI.Visible instead:

script.Parent.Parent.Parent.ResetOnSpawn.Visible = false
2 Likes

ResetOnSpawn is a screengui property.

1 Like

So when a player clicks the button it disables the gui property resetonspawn, correct? By the way which kinda script is this or where did you put it I just want all the details.

1 Like

Not exactly sure what you are trying to accomplish or I don’t understand that much about what you are trying to do must this should help you: LayerCollector.ResetOnSpawn

Local script. (CHARATERS LIMIT)

Script looks fine, I’m assuming the script is in an incorrect location and/or the gui’s reference is incorrect.

1 Like

Except, OP didn’t word it to my understanding of the GUI object being a ScreenGui. You can’t blame me for being wrong.

So, analyzing in ROBLOX Studio, the script did not work because it could not find the Parent of the GUI as only putting script.Parent.Parent.Parent.ResetOnSpawn = false … Not to mention that you forgot to create a variable that prints a parent value for the ClickDetector that will make the part (aka button) work.

I would recommend you creating like this sample:

local clickDetector = script.Parent -- Making a value for ClickDetector informing that he is the parent for the script
local button = game.Workspace.TestingButton -- Making a value to inform what/where the part is located at the Workspace
local TestingScreenGUI = game.StarterGui.ScreenGui -- Making a value to inform the location of the GUI, so we can change its properties of it.

clickDetector.MouseClick:Connect(function()
   TestingScreenGUI.ResetOnSpawn = false -- Informing that once clicking the button, it should disable the option ResetOnSpawn by giving an opposite answer, "false".
    if TestingScreenGUI.ResetOnSpawn == false then
        print("ResetOnSpawn has been disabled") -- Prints a message to verify if the ResetOnSpawn truly was disabled.
    else
        print("Something is not correct!") -- In case the script is printing something wrong, we make a conditional statement stating about it, "else".
    end
end)