The code below is being used for a main menu screen. All the variables are on top. The MouseClickEvents are for various buttons on the main menu. ‘‘Chapter Select’’ opens a Chapter Selection Menu and makes the actual Main Menu fade out. This section works perfectly!
The problem is that, when I hit the exit button on the Chapter Selection Menu, it fades, but then the main menu fades in way too slow, almost as if it is being bogged down or lagging. I’ve tried adding waits, etc. I could use some insight. Thank you.
local BottomShadow = script.Parent.BottomShadow
local ChapterSelect = script.Parent.ChapterSelect
local Updates = script.Parent.Updates
local Exit = script.Parent.Exit
local MenuLogo = script.Parent.MenuLogo
local ChapterMenu = script.Parent.Chapters
local ChapterShadow = script.Parent.Chapters.ChapterShadow
local ChapterShadow2 = script.Parent.Chapters.ChapterShadow2
local ChapterShadow3 = script.Parent.Chapters.ChapterShadow3
local ChapterOne = script.Parent.Chapters.ChapterOne
local ChapterTwo = script.Parent.Chapters.ChapterTwo
local ChapterThree = script.Parent.Chapters.ChapterThree
local PickAChapter = script.Parent.Chapters.PickAChapter
local ExitText = script.Parent.Chapters.ExitText
local ExitButton = script.Parent.Chapters.ExitButton
local debounceTime = 3 --allow click once per 2 seconds
local debounce = false
-- Main Menu Appearing
wait(60)
for i = 1, 0, -0.01 do
ChapterSelect.Visible = true
LogoShadow.BackgroundTransparency = i
BottomShadow.BackgroundTransparency = i
ChapterSelect.TextTransparency = i
ChapterSelect.TextStrokeTransparency = i
Updates.TextTransparency = i
Updates.TextStrokeTransparency = i
Exit.TextTransparency = i
Exit.TextStrokeTransparency = i
MenuLogo.TextTransparency = i
MenuLogo.TextStrokeTransparency = i
wait(0.01)
end
--Main Menu Disappearing (To Show Chapter Selection Screen) + Chapter Screen Appearing
script.Parent.ChapterSelect.MouseButton1Click:Connect(function()
print ("Main Menu Disappearing -- Chapter Screen Appearing!")
if debounce then return end
debounce = true
for i = 0, 1, 0.01 do
LogoShadow.BackgroundTransparency = i
BottomShadow.BackgroundTransparency = i
ChapterSelect.TextTransparency = i
ChapterSelect.TextStrokeTransparency = i
Updates.TextTransparency = i
Updates.TextStrokeTransparency = i
Exit.TextTransparency = i
Exit.TextStrokeTransparency = i
MenuLogo.TextTransparency = i
MenuLogo.TextStrokeTransparency = i
wait(0.01)
end
wait(3)
for i = 1, 0, -0.01 do
ChapterSelect.Visible = false
ChapterShadow.BackgroundTransparency = i
ChapterShadow2.BackgroundTransparency = i
ChapterShadow3.BackgroundTransparency = i
ChapterOne.TextTransparency = i
ChapterOne.TextStrokeTransparency = i
ChapterTwo.TextTransparency = i
ChapterTwo.TextStrokeTransparency = i
ChapterThree.TextTransparency = i
ChapterThree.TextStrokeTransparency = i
ExitText.TextTransparency = i
ExitText.TextStrokeTransparency = i
PickAChapter.TextTransparency = i
PickAChapter.TextStrokeTransparency = i
ExitButton.TextTransparency = i
ExitButton.TextStrokeTransparency = i
wait(0.01)
end
task.wait(debounceTime)
debounce = false
wait(3)
ExitButton.MouseButton1Click:Connect(function()
print ("Main Menu Appearing -- Chapter Screen Closing!") --This is the slow part (fades in slow, everything else works fine.)
if debounce then return end
debounce = true
for i = 0, 1, 0.01 do
ChapterShadow.BackgroundTransparency = i
ChapterShadow2.BackgroundTransparency = i
ChapterShadow3.BackgroundTransparency = i
ChapterOne.TextTransparency = i
ChapterOne.TextStrokeTransparency = i
ChapterTwo.TextTransparency = i
ChapterTwo.TextStrokeTransparency = i
ChapterThree.TextTransparency = i
ChapterThree.TextStrokeTransparency = i
ExitText.TextTransparency = i
ExitText.TextStrokeTransparency = i
PickAChapter.TextTransparency = i
PickAChapter.TextStrokeTransparency = i
ExitButton.TextTransparency = i
ExitButton.TextStrokeTransparency = i
wait(0.01)
end
wait(3)
for i = 1, 0, -0.01 do
ChapterSelect.Visible = true
LogoShadow.BackgroundTransparency = i
BottomShadow.BackgroundTransparency = i
ChapterSelect.TextTransparency = i
ChapterSelect.TextStrokeTransparency = i
Updates.TextTransparency = i
Updates.TextStrokeTransparency = i
Exit.TextTransparency = i
Exit.TextStrokeTransparency = i
MenuLogo.TextTransparency = i
MenuLogo.TextStrokeTransparency = i
wait(0.01)
task.wait(debounceTime)
debounce = false
end
end)
end)