Hi all, I’ve tried to add a ‘cooldown’ period so it can’t be mashed and cause the GUI to get stuck in one position, but my script didn’t seem to work.
Here is what I wrote, isClicked represents the debounce function
-- Variables
local Main = script.Parent.Parent.Parent.Main
local Hide = script.Parent.Parent
local Close = script.Parent.Parent.Parent.Close
local Button = script.Parent
local CloseButton = Close.TextButton
local isClicked = false
-- Function
script.Parent.MouseButton1Down:Connect(function()
if Button.Text == "Hide" then do
if not isClicked then
isClicked = true
Main:TweenPosition(UDim2.new(0.3, 0,0, 0), "Out","Back", 1.75)
Hide:TweenPosition(UDim2.new(0.782, 0,0.018, 0), "Out","Back", 1.75)
CloseButton.Text = "Close"
Close:TweenSizeAndPosition(UDim2.new(0.092, 0,0.076, 0), UDim2.new(0.885, 0,0.018, 0), "Out","Back", 1.75)
wait (1.5)
Button.Text = "Show"
isClicked = false
elseif Button.Text == "Show" then do
if not isClicked then
isClicked = true
Main:TweenPosition(UDim2.new(0, 0,0, 0), "Out","Back", 1.75)
Hide:TweenPosition(UDim2.new(0.7, 0,0.018, 0), "Out","Back", 1.75)
Close:TweenSizeAndPosition(UDim2.new(0.177, 0,0.076, 0), UDim2.new(0.8, 0,0.018, 0), "Out","Back", 1.75)
wait (1.5)
CloseButton.Text = "Close Ride Panel"
Button.Text = "Hide"
isClicked = false
end
end
end
end
end
end)
Any help is greatly appreciated