GUI button not working

So I was creating this side bar and the code below does not work. Once I click the button to open the button, the GUI opens. Once I close it, the GUI closes. BUT when try to open the GUI again, it does not work.

local Frame = script.Parent

Frame.closebutton.Activated:Connect(function()
	Frame:TweenPosition(UDim2.new(0, 0, 0.2, 0))
	local clone = Frame.closebutton:Clone()
	clone.Name = "clonebutton"
	clone.Text = "<"
	clone.Parent = Frame
	clone.Position = Frame.closebutton.Position
	Frame.closebutton:Destroy()
end)

Frame:WaitForChild("clonebutton").Activated:Connect(function()
	Frame:TweenPosition(UDim2.new(-0.146, 0, 0.2, 0))
	local clone = Frame.clonebutton:Clone()
	clone.Name = "closebutton"
	clone.Text = ">"
	clone.Parent = Frame
	clone.Position = Frame.clonebutton.Position
	Frame.clonebutton:Destroy()
end)

Try to use .Visible instead of :Destroy() And use a if to check if the gui is on screen or not.

local Frame = script.Parent

Frame.closebutton.MouseButton1Click:Connect(function()
if Frame.closebutton.Visible == false then
Frame:TweenPosition(UDim2.new(0, 0, 0.2, 0))
local clone = Frame.closebutton:Clone()
clone.Name = “clonebutton”
clone.Text = “<”
clone.Parent = Frame
clone.Position = Frame.closebutton.Position
elseif
Frame.closebutton.Visible == true then
Frame:TweenPosition(UDim2.new(-0.146, 0, 0.2, 0))
local clone = Frame.clonebutton:Clone()
clone.Name = “closebutton”
clone.Text = “>”
clone.Parent = Frame
clone.Position = Frame.clonebutton.Position
end)