Having problems with getting a UI tween to close again after I’ve opened the button.
When you click the button the first time it should open (which it does) and set the name to “Open” - which it has decided not to. Then once you click it again it should realise that the name is now “Open” and run the code that will close it.
Instead you get it opening fine, then when you go to close the UI it goes back to the opening animation.
local button = script.Parent
if button.Name == "Closed" then
local function onButtonActivated()
button.AnchorPoint = Vector2.new(0, 1)
button.Position = UDim2.new(0, 0, 1, 0)
wait(1)
button.AnchorPoint = Vector2.new(0.5, 0.5)
button:TweenSizeAndPosition(UDim2.new(0.4, 0, 0.4, 0), UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint)
-- Perform expected button action(s) here
wait(1)
button.Name = "Open"
end
button.Activated:Connect(onButtonActivated)
wait(1)
else
local function onButtonClick()
print("Here")
wait(1)
button.AnchorPoint = Vector2.new(0, 1)
button:TweenSizeAndPosition(UDim2.new(0, 200, 0, 50), UDim2.new(0, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint)
-- Perform expected button action(s) here
wait(1)
button.Name = "Closed"
end
button.Activated:Connect(onButtonClick)
end