UI Button that disable all Buttons in experience

Hello Developers!

I lastly tried searching for some tutorials on how to make button that closes or make all buttons in experience disappear when clicked. But i was not able to find any.

And I totally suck at scripting too, which means i don’t have any other option than trying to ask you guys here.

Basically everything i want is just a button that would close all buttons when touched and show the buttons again if touched again.

I would be really happy for any help!

Thanks in advance
-jeziskrista

Touched? Are you implying this is a physical 3D button?

ingame; guihide.rbxl (62.2 KB)

local button = script.Parent
local buttonGui = button.Parent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild(“PlayerGui”)

local guiStates = {}
local guisVisible = true

button.MouseButton1Click:Connect(function()
guisVisible = not guisVisible

for _, gui in pairs(playerGui:GetChildren()) do
	if gui:IsA("ScreenGui") and gui ~= buttonGui then 
		if guisVisible then
			gui.Enabled = guiStates[gui] or false
		else
			guiStates[gui] = gui.Enabled
			gui.Enabled = false 
		end
	end
end

end)

1 Like

That would disable the entire PlayerGui, not just GuiButtons. There’s also no need to store GUI state; you can simply set Gui.Enabled to guiVisible

2 Likes

I probably made it confusing, I’m not doing 3d, just classic Text Button

I guess I’m missing something… Not sure what tho…

Just tried modifying it by AI and me, and it works now. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.