Gui refuses to open on click

I would love for anyone to help me with this issue!
Every time i click on this imagebutton, it refuses to open the infoframe gui.

local frame = script.Parent.Parent.InfoFrame 
local button = script.Parent 
local function click()
	
button.MouseButton1Click:Connect(click) 
	if frame.Visible == false then 
		frame.Visible = true 
	else 
		frame.Visible = false 
	end
end

I’ve tried looking for solutions to this but to no avail

You are connecting to the button inside the function.
You need to do it like:

local frame = script.Parent.Parent.InfoFrame 
local button = script.Parent 
local function click()
	if frame.Visible == false then 
		frame.Visible = true 
	else 
		frame.Visible = false 
	end
end
button.MouseButton1Click:Connect(click)

And if you are just gonna change the Visible property you can just use:

local frame = script.Parent.Parent.InfoFrame 
local button = script.Parent 
local function click()
	frame.Visible = not frame.Visible
end
button.MouseButton1Click:Connect(click)

Hmm, both of those aren’t working for me.

Could you provide the properties of the instance, and the parent screengui

Ok lets try to debug then.
Is the script a localscript and where is it?
Does it give out any errors?
Can you send a screenshot of the gui in explorer?

Yes, the script is a localscript, It does NOT give out any errors

Heres the GUI in explorer
explorer
Opened up
aa

Can you check if the script runs at all like:

local function click()
	print("Clicked!")
	frame.Visible = not frame.Visible
end

and also try to check if it actually becomes visible thru the explorer while running.

The issue might be that you’re affecting the gui thats is in starterGui, and not the gui that gets replicated to the PlayerGui on runtime. Depending on what you’re affecting and where you placed your script this might be the issue

It runs, but still doesnt open.
Checked the explorer but it doesnt toggle the visibility.

Are you sure that the frame’s Position or Size is correct? Sometimes they are randomly set to values that make the frame invisible.