Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Button wont open menu?

Asked by 9 years ago

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

Log in to vote
2
Answered by 9 years ago

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!

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 CrispyBrix 113 — 9y
0
Never mind I got it working, couldn't use map, box, pic. I had to do them separately. Thanks. :) CrispyBrix 113 — 9y
0
Button1Down is an event for the mouse. OldPalHappy 1477 — 7y
Ad
Log in to vote
0
Answered by 9 years ago

Try using MouseButton1Down instead of Button1Down

Log in to vote
0
Answered by 9 years ago

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

Answer this question