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

Button wont open menu?

So I got this button, its supposed to Open a menu when left clicked and close it when clicked again. But I get "Button1Down is not a valid member of TextButton". Heres the code:

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


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



Not sure why it's saying this or what I am supposed to do about it. It's in a local script that's inside the button btw. Help please? :)

3 answers

✓ Accepted answer

Button1Down does not exist in Lua. You can use 'MouseButton1Down', 'MouseButton1Click', 'MouseButton1Up' (for the left click button) and 'MouseButton2Down', 'MouseButton2Click', or 'MouseButton2Up'. Try using this script instead:

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


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

If my answer helped, please give it a thumbs up and accept it. Thank you!

3 comments

0

It helped for the click part but still nothing comes up. But now there's nothing in the output xD Thumbs up anyways. :D

0

Never mind I got it working, couldn't use map, box, pic. I had to do them separately. Thanks. :)

0

Button1Down is an event for the mouse.

That's because Button1Down doesn't exist. However, try MouseButton1Down and it should work.

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