Hello, guys. I need someone to solve this script problem. There is an issue with my GUI, it will not let me to tween back even there is no error in the output. Anyone else?
Honestly, it’s probably because you nested the functions inside eachother. I would have a variable for whether or not the menu is currently open, and use that as my check.
local M = script.Parent.Parent.Parent:WaitForChild("SwirlyzMenu").Menu
local Open = false
script.Parent.MouseButton1Click:connect(function()
if Open == false then
Open = true
wait(1)
M:TweenPosition(UDim2.new(2.069, 0, 0.826, 0), 'Out', 'Quad',0.5)
script.Parent.Text = "Close"
wait(1)
else
wait(1)
M:TweenPosition(UDim2.new(10, 0, 0.826, 0), 'Out', 'Quad',0.5)
script.Parent.Text = "Open"
wait(1)
Open = false
end
end)
In this case, when the button is clicked the script will check whether or not the menu is “open”. If not, open it & change the button text. If so, close it and change the button text.
Whoo! Thank you so much! I carefully read your script, my brain got farted after reading it. I forgot to add if and then as it would help me to proceed the functions properly.
I’m not 100% certain, but the way I wrote the code I’m pretty sure you could get rid of the waits and it wouldn’t matter if people spammed the button, it wouldn’t break it.
local M = script.Parent.Parent.Parent:WaitForChild("SwirlyzMenu").Menu
local Open = false
script.Parent.MouseButton1Click:connect(function()
if Open == false then
M:TweenPosition(UDim2.new(2.069, 0, 0.826, 0), 'Out', 'Quad',0.5)
script.Parent.Text = "Close"
wait(1)
Open = true
else
M:TweenPosition(UDim2.new(10, 0, 0.826, 0), 'Out', 'Quad',0.5)
script.Parent.Text = "Open"
wait(1)
Open = false
end
end)