whoever solves this simple problem i am having will get a solution
I am making a shop. You click the TextButton to open the Frame and you click the X button to close the Frame. Simple.
The problem is when I open the shop and I use the X button instead of the open button to close the Frame, when I try to open the Frame again I have to click the Open button twice. I’ve tried everything I can think of to solve my problem but came up with nothing and here is my code in the open button
local Visible = false
local Button = script.Parent
local Frame = Button.Parent.ShopFrame
Frame.Position = UDim2.new(0.5, 0, 1.5, 0)
Frame.Visible = false
Button.MouseButton1Down:Connect(function()
if not Visible then
Frame.Visible = true
Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
0.25,
false)
task.wait(0.5)
Visible = true
else
Frame:TweenPosition(UDim2.new(0.5, 0, 1.5, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
0.25,
false)
task.wait(0.5)
Visible = false
Frame.Visible = false
end
end)
and here is the code in my X button located inside of the frame
local Visible = false
local Button = script.Parent
local Frame = script.Parent.Parent
Button.MouseButton1Down:Connect(function()
Frame:TweenPosition(UDim2.new(0.5, 0, 1.5, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
0.25,
false)
task.wait(0.5)
Visible = false
Frame.Visible = false
end)