Problem with making button doesnt go invisible

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make when you press the button it goes unvisible.
  2. What is the issue? Include screenshots / videos if possible!
    no erros, but it prints.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried like everything!
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code blocklocal
local frame = script.Parent.Parent.GameFrame
local b1 = script.Parent.Parent.GameFrame.Button1
local button = script.Parent

if button.MouseButton1Click:Connect(function()
		frame.Visible = true
	end)
then
	
end
repeat
wait(1)
until
b1.MouseButton1Click:Connect(function()
	b1.Visible = true
	print("prints")
end)
1 Like

if statements aren’t event listeners, they only fire once. You need to bind your button.MouseButton1Click to a event then listen for when it is toggled from invisible to visible.

But i dont understand because it works with the print

you arent apply a condition for it. when you say if button.MouseButton1Click or more importantly when saying if to a function you are waiting for it to become true or return a value. Since, 1 you are waiting for it to be true in until and you are defining it as a event listener and not a conditional there

As CoderHusk said if statements are not event listeners.
If you’re trying simply to have a button that makes the frame visible and a button that makes ‘Button1’ visible then this should work fine:

local frame = script.Parent.Parent.GameFrame
local b1 = script.Parent.Parent.GameFrame.Button1
local button = script.Parent

button.MouseButton1Click:Connect(function()
	frame.Visible = true
end)

b1.MouseButton1Click:Connect(function()
	b1.Visible = true
	print("prints")
end)

I recommend checking the article Handling Events and MouseButton1Click

1 Like

So you wan the button to become visible or invisible?

Invisible sir im reading the article about MouseButton1Click and making new script . But help is appreciated.

Oh, if you’re trying to make it invisible then you’d just set the Visible property to false.
The script would be like this:

local frame = script.Parent.Parent.GameFrame
local b1 = script.Parent.Parent.GameFrame.Button1
local button = script.Parent

button.MouseButton1Click:Connect(function()
	frame.Visible = false
end)

b1.MouseButton1Click:Connect(function()
	b1.Visible = false
	print("prints")
end)

Ye i realized like 1 second after I typed that like lol

Okay sorry all the original actually worked but I needed to but in invisible and i used true lol but now i put it to false and everything works thanks for evryone!

You can check its visibility property on click and decide whether it should be visible or not from there

1 Like