So, I am trying to make a gui open/close with tweening, can someone explain why this is not working? It will open, but it will not close afterwards.
script.Parent.MouseButton1Click:Connect(function() local work = false if work == false then work = true script.Parent.Parent:TweenPosition(UDim2.new(0.736, 0,0.304, 0)) wait(1) else work = false script.Parent.Parent:TweenPosition(UDim2.new(0.932, 0, 0.304, 0)) wait(1) end end)
This is a local script. Any help will be greatly appreciated.
Make work a script-wide variable.
The issue here is that your variable, work, is being created from inside the function - and thus is never actually true and not up-to-date with the current state of your UI.