wait(0.01) is the same as wait() since the shortest length of time a wait() command can yield for is 1/60th of a second which is 0.0166… seconds.
local button = script.Parent
local clicks = 0
local DB = false
local Image = script.Parent.Parent.ImageLabel
local buttonGUI = game.Players.LocalPlayer.PlayerGui.MissionsButtonCloseGUI.Frame
local Bar = game.Players.LocalPlayer.PlayerGui.MissionsGUI.Bar
local Mission1 = game.Players.LocalPlayer.PlayerGui.MissionsGUI.Mission1
local TweenService = game:GetService("TweenService")
if clicks == 0 then
button.MouseButton1Click:Connect(function()
Bar:TweenPosition(UDim2.new(-0.002, 0,1.803, 0),"Out","Sine",2,false)
Mission1:TweenPosition(UDim2.new(0.05, 0,1.803, 0),"Out","Sine",2,false)
buttonGUI:TweenPosition(UDim2.new(0.781, 0,0.895, 0),"Out","Sine",2,false)
clicks = clicks + 1
task.spawn(function()
while Image.Rotation <= 269 do
Image.Rotation = Image.Rotation + 10
task.wait()
end
return
end)
end)
end
if clicks == 1 then
button.MouseButton1Click:Connect(function()
Bar:TweenPosition(UDim2.new(-0.002, 0,0.803, 0),"Out","Sine",2,false)
Mission1:TweenPosition(UDim2.new(0.05, 0.924, 0),"Out","Sine",2,false)
buttonGUI:TweenPosition(UDim2.new(0.781, 0,0.699, 0),"Out","Sine",2,false)
clicks = clicks - 1
task.spawn(function()
while Image.Rotation <= 89 do
Image.Rotation = Image.Rotation - 10
task.wait()
end
return
end)
end)
end
You will likely need to add a debounce to prevent the functions from executing too much. Read more here: