script.Parent.Parent.Parent.Parent.Enabled = false is hiding BUTTON

In my button script, I have

script.Parent.Parent.Parent.Parent.Enabled = false

and its hiding the BUTTON, not the ScreenGui

Full script:

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent:WaitForChild('haveToBuy').Value == true then return
	else
		game.ReplicatedStorage.Tool:FireServer(script.Parent.Parent.Number.Value)
		script.Parent.Parent.Parent.Parent.Enabled = false
	end
end)

If the button is a child of the ScreenGui, maybe you are accidentally calling it. Try adding another .Parent

Show us your explorer, we can’t help you if you haven’t provided any information.

1 Like

Its in 2 frames and 1 ScreenGui

Are you sure you parented your other GUI elements to the same ScreenGui object? The button itself doesn’t have a property called “Enabled”, so it should really be printing out an error if you are referencing the wrong object. Any console output?

1 Like

It has to be disabling the ScreenGui because buttons don’t have an Enabled property.

This is a little vague, can you maybe do something like this:

ScreenGui
   Frame
     Frame
        -- and so on

It has to be disabling the ScreenGui because buttons don’t have an Enabled property.

Ikr

This is a little vague, can you maybe do something like this:

ScreenGui
Frame
Frame
Button

And no errors or warnings that’s what’s so weird.

The script is correct, did you check what the ScreenGui’s Enabled property is in the explorer during a play test?

Check it in PlayerGui

Players 
   [Your Name]
      PlayerGui
          ScreenGui

Just to make this easier for us, could you send a place file?

Check it in PlayerGui

I did

The script is correct, did you check what the ScreenGui’s Enabled property is in the explorer during a play test?

It stays disabled it starts out disabled

Please provide a place file or at least show us a screenshot of your UI.

I figured it out, it is a copy of another gui that was under it and it hid it but showed the one with the button no visible