I'm making a tweening hide/show GUI script, and when you hide the GUI it sets a "hidden" variable to true, so that the same hide code doesn't get executed again. The problem is that when you're supposed to show it, the hidden variable doesn't get changed to false and the GUI won't open back up. Here's my code:

local Frame = script.Parent.Parent.Frame
local hidden = false

function callback(isDone)
	if isDone then
		print("Tween successful.")
	else
		print("Tween failed.")
	end
end

script.Parent.MouseButton1Click:Connect(function(TweenInfo)
	if hidden == false then
		Frame:TweenSize(UDim2.new(0,0,0,0), "InOut", "Quint", 1.5, true, callback)
		local hidden = true
		print(hidden)	
	else
		Frame:TweenSize(UDim2.new(0,682,0,390), "InOut", "Quint", 1.5, true, callback)
		local hidden = false
		print(hidden)
	end
end)

Any ideas? I've been at this issue for a while now and I'm quite confused. Any help would be very appreciated.

4 comments

0

Why dont you just wait for the tween to finish and then delete the GUI?

0

Because I want the GUI to show up again. I don't just want it to be gone entirely.

0

remove the "local" from line 15 and 19

0

That worked, thank you.