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

Button does not work?Please help me , the coding can be wrong and it is in an local script

Asked by 7 years ago

I have made an Button script but it workes on the roblox studio but when I pay the game and press the button it don't want to open

local open = false script.Parent.MouseButton1Click:connect(function() if frame.Visible == false then frame.Visible = true else frame.Visible = false end

0
Is that the whole script? Cause you never defined what your 'frame' variable is. Le_Teapots 913 — 7y
0
What tiraner300 said, this doesn't appear to be your whole script, unless you just forgot to define what 'frame' was. Also if the click event is only supposed to toggle the frames invisibility, just use 'frame.Visible = not frame.Visible'. That'll just reverse what it currently is. Troidit 253 — 7y
0
Instead of otherwise adding extra lines to ask what visibility it currently is. Troidit 253 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Hello there! I'm BlackOrange and I'm here to help!

To start off, next time use code block.

Anyway, you don't need the variable Open unless your tweening and you could wait until Tween is complete, other then that it's not necessary. To make a nice Frame Open and Close with 1 button just requires a little bit of knowledge.

Let's start off with variables: Note that you need LocalScript

1local Button = script.Parent
2local Frame = ??? -- you gotta set where frame is

Now, let's use the MouseButton1Down function:

1local Button = script.Parent
2local Frame = ??? -- you gotta set where frame is
3 
4Button.MouseButton1Down:Connect(function() -- use :Connect, :connect is deprecated
5 
6end)

Now let's give it a command:

01local Button = script.Parent
02local Frame = ??? -- you gotta set where frame is
03 
04Button.MouseButton1Down:Connect(function() -- use :Connect, :connect is deprecated
05    if Frame.Visible == true then
06        Frame.Visible = false
07    else
08        Frame.Visible = true
09    end
10end)

Now with what we have, it checks the frame's visibility and then changes the visibility based on what it's current value is.

Make sure you define your frame!

Hopefully this helped! Best of luck

-- BlackOrange3343

Ad

Answer this question