I can't find this event on the ROBLOX wiki so i'll ask here.
What's the event that fires AFTER the player clicks a button the 2nd time? For example, if they click a button to make a GUI visible i want them to click it again to close it.
You'd use MouseButton1Down or MouseButton1Click. If you want it to close, use a variable.
open = false vis = script.Parent.Parent -- Should lead to what you want to be Visible/Invisible sp = script.Parent sp.MouseButton1Down:connect(function() if not open then open = true vis.Visible = true elseif open then open = false vis.Visible = false end end)
There is no event to check if a player has clicked again. But there is a way you can do what you are talking about using variables:
open = false -- Gui is invisible by default gui = script.Parent.Parent -- Assuming script.Parent.Parent is a Frame or something that has a visible property, you can change this of course script.Parent.MouseButton1Down:connect(function() -- Assuming script.Parent is the button if open == false then -- If the gui isn't open gui.Visible = true -- Make the gui visible open = true -- Set the open variable to true else -- If it is open gui.Visible = false -- Make it invisible open = false -- Set the open variable to false end -- End the if statement end) -- End the function
local gui = script.Parent.Parent:WaitForChild("Frame") local button = script.Parent button.MouseButton1Click:connect(function() gui.Visible = not gui.Visible -- Makes it the opposite of what it currently is. button.Text = (gui.Visible and "Close" or "Open") -- Ternary operation to shorten it. --[[ if gui is visible then -- make the text Close --else -- make the text Open --]] end)