Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI will not come up after trying to fix it?

Alright, so I posted something about a GUI not coming up yesterday I think. I got some great responses and it was fixed, sort of. It would show up then disappear right after. Here was that code:

local open = script.Parent
local box = open.Frame
local map = box.Map
local pic = box.Mapic

open.MouseButton1Down:connect(function(mouse)
		
		pic.Visible = true
	map.Visible = true
	box.Visible = true
	open.Text = "Close"
		if open.Text == "Close" and open.MouseButton1Down then
		open.Text = "Teleport Menu"
	pic.Visible = false
	map.Visible = false
	box.Visible = false
		end
end)

So I tried using Debounce because I had no clue how to fix this or anything. Well, now nothing happens again. No output errors. Here is the code now:

local open = script.Parent
local box = open.Frame
local map = box.Map
local pic = box.Mapic
local enabled = true


open.MouseButton1Down:connect(function(mouse)
	if not enabled then
		
		enabled = false
		pic.Visible = true
	map.Visible = true
	box.Visible = true
	open.Text = "Close"
	wait(1)
		if open.Text == "Close" and open.MouseButton1Down then
		open.Text = "Teleport Menu"
	pic.Visible = false
	map.Visible = false
	box.Visible = false
	enabled = true
		end
		end
end)

Some help please? xD

1 answer

✓ Accepted answer

MouseButton1Down is an event, not a bool value or property. Here, I fixed it.

local open = script.Parent
local box = open.Frame
local map = box.Map
local pic = box.Mapic

local Opened = false --If the gui is opened by default, change this to true
open.MouseButton1Down:connect(function() --"mouse" has nothing to do with MouseButton1Down
	if Opened == false then
		Opened = true
		pic.Visible = true
		map.Visible = true
		box.Visible = true
		open.Text = "Close"
	else
		Opened = false
		open.Text = "Teleport Menu"
		pic.Visible = false
		map.Visible = false
		box.Visible = false
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.