currentgame = script.Parent.Parent.Parent -- all these don't need to be local, unless they are in a function or an if statement or a loop.
menu = script.Parent
play = script.Parent.Play
quit = script.Parent.Quit
upgrades = script.Parent.Upgrades
quitmenu = script.Parent.Parent.Quit
upgradesmenu = script.Parent.Parent.Upgrades
gamemenu = script.Parent.Parent.Game
play.MouseButton1Down:connect(function()--event
if currentgame.Visible then--no need for == true
gamemenu.Visible = true
menu.Visible = false
end
end)
quit.MouseButton1Down:connect(function()
if currentgame.Visible then
quitmenu.Visible = true
menu.Visible = false
quitmenu:TweenPosition(UDim2.new(0, 200, 0, 100))
end
--This part crashes studio vvvvvvvvvvvvvvvvvvvv
quitmenu.Yes.MouseButton1Down:connect(function()
menu:TweenPosition(UDim2.new(0, -400, 0, 100))
quitmenu:TweenPosition(UDim2.new(0, -400, 0, 100))
quitmenu.Visible = false
menu.Visible = true
currentgame.Visible = false
currentgame.Parent.Parent.Apps.Visible = true
end)
quitmenu.No.MouseButton1Down:connect(function()
menu.Visible = true
wait()
menu:TweenPosition(UDim2.new(0, 250, 0, 100))
quitmenu.Visible = false
end)
end)
Whenever the "quitmenu.Yes" is pressed, it crashes my roblox studio... please explain why this happens, thanks!

1 comment
Try putting a wait.