I’m currently trying to make a Main Menu that opens locally to the user. It has access to change teams, buy gamepasses, credits, settings and more. It also includes a tween when opening/closing.
The issue is that when the player closes the GUI, they can’t re-open it (it works the first time but when they close it, it won’t work anymore).
Code
Open button (Main)
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
game.Players.LocalPlayer.PlayerGui.MainMenu.Frame.Visible = false
debounce = true
local pos = game.StarterGui.MainMenu.Frame.Position
local object = game.StarterGui.MainMenu.Frame
game.Players.LocalPlayer.PlayerGui.MainMenu.Frame.Visible = true
object:TweenPosition(UDim2.new(0,0,0,-1), Enum.EasingDirection.Out, Enum.EasingStyle.Elastic, 2)
wait(2.2)
debounce = false
else
game.Players.LocalPlayer.PlayerGui.MainMenu.Open.Text = "You are clicking too fast!"
game.Players.LocalPlayer.PlayerGui.MainMenu.Open.Text = "Menu"
end
end)
Close Button
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
local pos = script.Parent.Parent.Parent.Frame.Position
local object = script.Parent.Parent.Parent.Frame
object:TweenPosition(UDim2.new(0,0,-2,0), Enum.EasingDirection.Out, Enum.EasingStyle.Elastic, 2)
wait(2.2)
game.Players.LocalPlayer.PlayerGui.MainMenu.Frame.Visible = false
debounce = false
else
game.Players.LocalPlayer.PlayerGui.MainMenu.Frame.Play.Text = "You are clicking too fast!"
wait(2)
game.Players.LocalPlayer.PlayerGui.MainMenu.Frame.Play.Text = "Play"
end
end)
Possible error
“Not running script because past shutdown deadline” - Not sure that this means.