Debounce won’t work
local changeMenuDebounce = false
local transitionTime = .3
function displayMenu(val)
local function tweenText(i, val)
return TweenService:Create(i, TweenInfo.new(transitionTime, Enum.EasingStyle.Quint,
Enum.EasingDirection.Out), {
TextTransparency = val
}):Play()
end
if val > #Menus then
warn('Invalid value')
return
end
for _,menu in pairs(bg.MenuBG:GetChildren()) do
menu.Visible = false
end
Menus[val].Visible = true
local next = ""
local before = ""
if val == #Menus then
--// max menu
Next = Menus[#Menus - #Menus + 1].Name
else
Next = Menus[val + 1].Name
end
if val == 1 then
--// least menu
before = Menus[#Menus].Name
else
before = Menus[val - 1].Name
end
tweenText(topSelector.NextDisplay, 1)
tweenText(topSelector.BeforeDisplay, 1)
tweenText(topSelector.DisplayText, 1)
task.wait(transitionTime)
topSelector.NextDisplay.Text = "< "..string.upper(Next)
topSelector.BeforeDisplay.Text = string.upper(before).. " >"
topSelector.DisplayText.Text = string.upper(Menus[val].Name)
tweenText(topSelector.NextDisplay, .84)
tweenText(topSelector.BeforeDisplay, .84)
tweenText(topSelector.DisplayText, 0)
end
function updateSelectedMenu(goBack)
if goBack then
if SelectedMenu == 1 then
SelectedMenu = #Menus
else
SelectedMenu -= 1
end
elseif not goBack then
if SelectedMenu == #Menus then
SelectedMenu = 1
else
SelectedMenu += 1
end
end
print(SelectedMenu)
displayMenu(SelectedMenu)
end
--// Scripting
Next.MouseButton1Click:Connect(function()
if not changeMenuDebounce then
updateSelectedMenu()
changeMenuDebounce = true
task.wait(transitionTime)
changeMenuDebounce = false
end
end)
Back.MouseButton1Click:Connect(function()
if not changeMenuDebounce then
updateSelectedMenu(true)
changeMenuDebounce = true
task.wait(transitionTime)
changeMenuDebounce = false
end
end)