You said it yourself, you just set the enabled property to false. You'd do this by using a couple of if statements to check the state of the Gui (is it opened or closed?). If it's open, then close it, and vice versa
local gui = script.Gui
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
brickClickedEvent.OnClientEvent:Connect(function()
if gui.Enabled = true then
gui.Enabled = false
elseif gui.Enabled = false then
gui.Enabled = true
end
end)
That code is fine, and it does its job. But why type all that when you can do it in fewer lines using the not operator?
local gui = script.Gui
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
brickClickedEvent.OnClientEvent:Connect(function()
gui.Enabled = not gui.Enabled
end)
Essentially, the not operator inverts whatever it's operating on - true becomes false and false becomes true! Always be on the look out for where you can reduce your code and effort like this, although, don't obsess over doing this as it could impede the quality of your code. :)