This is what i tried, but failed hard hahaha then, realized if this did work my button would be hidden and then the players wouldn't be able to see the button to show the gui again....is it even possible to do this?
local hgui = script.Parent local gui = game.StarterGui.ScreenGui hgui.MouseButton1Click:Connect(function() gui.Enabled = false end)
First of all, StarterGui
is just a storage for guis which are later cloned into PlayerGui
, so modifying the one inside there won't do anything, You need to modify the already cloned one.
Second of all, you don't have to hide the entire gui. You can hide the main frame, but for example keep a button which let's you open the gui again.
local gui = script:FindFirstAncestorOfClass("ScreenGui") --feel free to replace with the actual path local button = script.Parent local main = gui.Frame --replace this button.MouseButton1Click:Connect(function() main.Visible = not main.Visible --this will toggle the state between true and false end)