Any tips on cleaning my Guis Code?

Hello! I am currently working on a game and I have almost finished the code for a main menu.

So far everything works perfectly fine but I am just not satisfied with the code, I feel like the code could look a lot cleaner, and there are pieces of code that I feel can be done better if you know what I mean.

There are a lot more scripts for the Guis that I’ve encountered this dissatisfaction for but I’m just going to focus on one because they are decently similar. Any tips on making the code cleaner?

--[Get Game Services]
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--[Get Player Variables]
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

--[Get Required Modules]
local FadeModule = require(game:GetService("ReplicatedStorage").Module.FadeModule)
local TypeWriteModule = require(game:GetService("ReplicatedStorage").Module.TypeWrite)
local IconSpriteData = require(game:GetService("ReplicatedStorage").IconSpriteData)

--[Get MainMeny Variables]
local MainMenuGui = game:GetService("ReplicatedStorage").Guis:WaitForChild("MainMenu")
local Background = MainMenuGui:WaitForChild("Background")
local TopCaption = MainMenuGui:WaitForChild("TopCaption")
local ExitTag = MainMenuGui:WaitForChild("ExitTag")
local MenuID = MainMenuGui:WaitForChild("ID")
local MenuItems = MainMenuGui:WaitForChild("MenuItems")
local MenuLabel = MainMenuGui:WaitForChild("MenuLabel")

--[Get MainMenuID Variables]
local Data = MenuID:WaitForChild("Data")
local DataLabels = Data:WaitForChild("Labels")
local FightIcons = MenuID:WaitForChild("FightIcons")
local PlayerIcon = MenuID:WaitForChild("Icon")

--[Get MainMenuItems Variables]
local ItemContainer = MenuItems:WaitForChild("Container")
--[Item Table]
local ItemTable = {
	Continue = ItemContainer["1-Continue"],
	ChangeNames = ItemContainer["2-Change Names"],
	DeleteSave = ItemContainer["3-Delete Save"],
	Help = ItemContainer["4-Help"],
	Jukebox = ItemContainer["5-Jukebox"],
	Settings = ItemContainer["6-Settings"]
}
--[Other MainMenuItems Variables]
local ArrowLeft = MenuItems:WaitForChild("ArrowLeft")
local ArrowRight = MenuItems:WaitForChild("ArrowRight")
local UIPageLayout = ItemContainer:WaitForChild("UIPageLayout")

--[Other Required Variables]
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local GameGui = ReplicatedStorage.Remote:WaitForChild("GameGui")
local FadeScreen = ReplicatedStorage.Remote:WaitForChild("FadeScreen")
local DataValues = ReplicatedStorage:WaitForChild("DataValues")
local PlayerData = DataValues:WaitForChild("PlayerData")
local cam = workspace.CurrentCamera

--[Set Up Variables]
Background.ImageTransparency = 1
TopCaption.Position = UDim2.new(-1, 0, 0, 0)
MenuID.Position = UDim2.new(0, 0, -1, 0)
MenuItems.Position = UDim2.new(0, 0, 1, 0)
for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end
for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end

--[Gui Debug Boolean]
local GuiEnabled = false

--[Function List]
function RefreshMenuItems()
	DataLabels._Name.Text = (PlayerData.PlayerName.Value)
	DataLabels.Team.Text = (PlayerData.TeamName.Value)
	DataLabels.Chapter.Text = (PlayerData.Chapter.Value)
	DataLabels.PlayTime.Text = (DataValues.PlayTime.Value)
	PlayerIcon.Image = IconSpriteData.SpriteIcons[PlayerData.Player.Value]
end

function ChangeItemColor(Object)
	Object.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	Object.BackgroundTransparency = 0.5
	Object.ImageTransparency = 0.4
	Object.UIStroke.Thickness = 3
	Object.UIStroke.Color = Color3.new(0.258824, 0.258824, 0.258824)
end

function DebugItems()
	for i, Object in pairs(ItemTable) do
		ChangeItemColor(Object)
	end
end

function HighlightCurrentItem()
	UIPageLayout.CurrentPage.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	UIPageLayout.CurrentPage.BackgroundTransparency = 0
	UIPageLayout.CurrentPage.ImageTransparency = 0
	UIPageLayout.CurrentPage.UIStroke.Thickness = 6
	UIPageLayout.CurrentPage.UIStroke.Color = Color3.new(1, 1, 1)
end

function ChangePageLeft()
	DebugItems()
	UIPageLayout:Previous()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowLeft.Position = UDim2.new(0.391, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowLeft:TweenPosition(UDim2.new(0.401, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

function ChangePageRight()
	DebugItems()
	UIPageLayout:Next()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowRight.Position = UDim2.new(0.570, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowRight:TweenPosition(UDim2.new(0.559, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

function PanItemsIn()
	RefreshMenuItems()
	GuiEnabled = true
	MenuID.Position = UDim2.new(0, 0, -1, 0)
	MenuItems.Position = UDim2.new(0, 0, 1, 0)
	MenuID:TweenPosition(UDim2.new(0, 0, 0.112, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 0.614, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		wait(0.025)
	end
	wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		wait(0.025)
	end
	FadeModule:FadeText(ExitTag, 0, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 0, 0.3)
end

function PanItemsOut()
	MenuID.Position = UDim2.new(0, 0, 0.112, 0)
	MenuItems.Position = UDim2.new(0, 0, 0.614, 0)
	FadeModule:FadeText(ExitTag, 1, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 1, 0.3)
	wait()
	MenuID:TweenPosition(UDim2.new(0, 0, -1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 0.5, true)
	wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		wait(0.025)
	end
	wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		wait(0.025)
	end
end

function PanMenuItemFunction(Gui, Direction)
	if Gui == "Main Menu Items" then
		if Direction == "In" then
			PanItemsIn()
		elseif Direction == "Out" then
			PanItemsOut()
		else
		end
	else
		--Do Nothing
	end
end

function MainMenuScreenInit(Gui)
	if Gui == "Main Menu" then
		GuiEnabled = true
		MenuLabel.Text = ""
		MainMenuGui.Parent = PlayerGui
		RefreshMenuItems()
		FadeModule:FadeImage(Background, 0, 1)
		Sounds.OST["2: Main Menu"]:Play()
		Sounds.OST["2: Main Menu"].Volume = 1
		wait(1)
		DebugItems()
		HighlightCurrentItem()
		PanItemsIn()
		MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
		MenuLabel.TextTransparency = 1
		MenuLabel.UIStroke.Transparency = 1
		MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
		FadeModule:FadeText(MenuLabel, 0, 0.2)
		FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
		MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	else
		--Do Nothing
	end
end

function MouseClickLeft()
	ChangePageLeft()
end

function MouseClickRight()
	ChangePageRight()
end

--[UserInputService]
UserInputService.InputBegan:Connect(function(InputObject)
	if GuiEnabled then
		if InputObject.KeyCode == Enum.KeyCode.Left then
			ChangePageLeft()
		end

		if InputObject.KeyCode == Enum.KeyCode.Right then
			ChangePageRight()
		end

		if InputObject.KeyCode == Enum.KeyCode.Space then
			GuiEnabled = false
			if UIPageLayout.CurrentPage.UIname.Value == "Continue" then
				print("Continue")
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				FadeModule:FadeAudio(Sounds.OST["3: Main Menu"], 0, 1)
				wait(1)
				FadeScreen:FireServer(2)
				wait(1)
				cam.CameraType = Enum.CameraType.Custom
				MainMenuGui.Parent = game:GetService("ReplicatedStorage"):WaitForChild("Guis")
			else
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				GameGui:FireServer(UIPageLayout.CurrentPage.UIname.Value)
			end
		end
	else
		--Do Nothing
	end
end)

--[Function Calls]
GameGui.OnClientEvent:Connect(PanMenuItemFunction)
GameGui.OnClientEvent:Connect(MainMenuScreenInit)
ArrowLeft.MouseButton1Down:Connect(MouseClickLeft)
ArrowRight.MouseButton1Down:Connect(MouseClickRight)

The script is local and it is stored in StarterPlayerScripts, and the Gui mentioned in the code is stored in ReplicatedStorage to reduce lag when running the game.

Any help will do, Thanks!

(posted this in the wrong spot originally xD)

Well, for starters, you already defined ReplicatedStorage in a variable, so there’s no need to call :GetService everytime you need it.

--[Get Game Services]
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--[Get Player Variables]
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

--[Get Required Modules]
local FadeModule = require(ReplicatedStorage.Module.FadeModule)
local TypeWriteModule = require(ReplicatedStorage.Module.TypeWrite)
local IconSpriteData = require(ReplicatedStorage.IconSpriteData)

--[Get MainMeny Variables]
local MainMenuGui = ReplicatedStorage.Guis:WaitForChild("MainMenu")
local Background = MainMenuGui:WaitForChild("Background")
local TopCaption = MainMenuGui:WaitForChild("TopCaption")
local ExitTag = MainMenuGui:WaitForChild("ExitTag")
local MenuID = MainMenuGui:WaitForChild("ID")
local MenuItems = MainMenuGui:WaitForChild("MenuItems")
local MenuLabel = MainMenuGui:WaitForChild("MenuLabel")

--[Get MainMenuID Variables]
local Data = MenuID:WaitForChild("Data")
local DataLabels = Data:WaitForChild("Labels")
local FightIcons = MenuID:WaitForChild("FightIcons")
local PlayerIcon = MenuID:WaitForChild("Icon")

--[Get MainMenuItems Variables]
local ItemContainer = MenuItems:WaitForChild("Container")
--[Item Table]
local ItemTable = {
	Continue = ItemContainer["1-Continue"],
	ChangeNames = ItemContainer["2-Change Names"],
	DeleteSave = ItemContainer["3-Delete Save"],
	Help = ItemContainer["4-Help"],
	Jukebox = ItemContainer["5-Jukebox"],
	Settings = ItemContainer["6-Settings"]
}
--[Other MainMenuItems Variables]
local ArrowLeft = MenuItems:WaitForChild("ArrowLeft")
local ArrowRight = MenuItems:WaitForChild("ArrowRight")
local UIPageLayout = ItemContainer:WaitForChild("UIPageLayout")

--[Other Required Variables]
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local GameGui = ReplicatedStorage.Remote:WaitForChild("GameGui")
local FadeScreen = ReplicatedStorage.Remote:WaitForChild("FadeScreen")
local DataValues = ReplicatedStorage:WaitForChild("DataValues")
local PlayerData = DataValues:WaitForChild("PlayerData")
local cam = workspace.CurrentCamera

--[Set Up Variables]
Background.ImageTransparency = 1
TopCaption.Position = UDim2.new(-1, 0, 0, 0)
MenuID.Position = UDim2.new(0, 0, -1, 0)
MenuItems.Position = UDim2.new(0, 0, 1, 0)
for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end
for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end

--[Gui Debug Boolean]
local GuiEnabled = false

--[Function List]
function RefreshMenuItems()
	DataLabels._Name.Text = (PlayerData.PlayerName.Value)
	DataLabels.Team.Text = (PlayerData.TeamName.Value)
	DataLabels.Chapter.Text = (PlayerData.Chapter.Value)
	DataLabels.PlayTime.Text = (DataValues.PlayTime.Value)
	PlayerIcon.Image = IconSpriteData.SpriteIcons[PlayerData.Player.Value]
end

function ChangeItemColor(Object)
	Object.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	Object.BackgroundTransparency = 0.5
	Object.ImageTransparency = 0.4
	Object.UIStroke.Thickness = 3
	Object.UIStroke.Color = Color3.new(0.258824, 0.258824, 0.258824)
end

function DebugItems()
	for i, Object in pairs(ItemTable) do
		ChangeItemColor(Object)
	end
end

function HighlightCurrentItem()
	UIPageLayout.CurrentPage.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	UIPageLayout.CurrentPage.BackgroundTransparency = 0
	UIPageLayout.CurrentPage.ImageTransparency = 0
	UIPageLayout.CurrentPage.UIStroke.Thickness = 6
	UIPageLayout.CurrentPage.UIStroke.Color = Color3.new(1, 1, 1)
end

function ChangePageLeft()
	DebugItems()
	UIPageLayout:Previous()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowLeft.Position = UDim2.new(0.391, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowLeft:TweenPosition(UDim2.new(0.401, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

function ChangePageRight()
	DebugItems()
	UIPageLayout:Next()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowRight.Position = UDim2.new(0.570, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowRight:TweenPosition(UDim2.new(0.559, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

function PanItemsIn()
	RefreshMenuItems()
	GuiEnabled = true
	MenuID.Position = UDim2.new(0, 0, -1, 0)
	MenuItems.Position = UDim2.new(0, 0, 1, 0)
	MenuID:TweenPosition(UDim2.new(0, 0, 0.112, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 0.614, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		wait(0.025)
	end
	wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		wait(0.025)
	end
	FadeModule:FadeText(ExitTag, 0, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 0, 0.3)
end

function PanItemsOut()
	MenuID.Position = UDim2.new(0, 0, 0.112, 0)
	MenuItems.Position = UDim2.new(0, 0, 0.614, 0)
	FadeModule:FadeText(ExitTag, 1, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 1, 0.3)
	wait()
	MenuID:TweenPosition(UDim2.new(0, 0, -1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 0.5, true)
	wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		wait(0.025)
	end
	wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		wait(0.025)
	end
end

function PanMenuItemFunction(Gui, Direction)
	if Gui == "Main Menu Items" then
		if Direction == "In" then
			PanItemsIn()
		elseif Direction == "Out" then
			PanItemsOut()
		else
		end
	else
		--Do Nothing
	end
end

function MainMenuScreenInit(Gui)
	if Gui == "Main Menu" then
		GuiEnabled = true
		MenuLabel.Text = ""
		MainMenuGui.Parent = PlayerGui
		RefreshMenuItems()
		FadeModule:FadeImage(Background, 0, 1)
		Sounds.OST["2: Main Menu"]:Play()
		Sounds.OST["2: Main Menu"].Volume = 1
		wait(1)
		DebugItems()
		HighlightCurrentItem()
		PanItemsIn()
		MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
		MenuLabel.TextTransparency = 1
		MenuLabel.UIStroke.Transparency = 1
		MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
		FadeModule:FadeText(MenuLabel, 0, 0.2)
		FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
		MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	else
		--Do Nothing
	end
end

function MouseClickLeft()
	ChangePageLeft()
end

function MouseClickRight()
	ChangePageRight()
end

--[UserInputService]
UserInputService.InputBegan:Connect(function(InputObject)
	if GuiEnabled then
		if InputObject.KeyCode == Enum.KeyCode.Left then
			ChangePageLeft()
		end

		if InputObject.KeyCode == Enum.KeyCode.Right then
			ChangePageRight()
		end

		if InputObject.KeyCode == Enum.KeyCode.Space then
			GuiEnabled = false
			if UIPageLayout.CurrentPage.UIname.Value == "Continue" then
				print("Continue")
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				FadeModule:FadeAudio(Sounds.OST["3: Main Menu"], 0, 1)
				wait(1)
				FadeScreen:FireServer(2)
				wait(1)
				cam.CameraType = Enum.CameraType.Custom
				MainMenuGui.Parent = game:GetService("ReplicatedStorage"):WaitForChild("Guis")
			else
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				GameGui:FireServer(UIPageLayout.CurrentPage.UIname.Value)
			end
		end
	else
		--Do Nothing
	end
end)

--[Function Calls]
GameGui.OnClientEvent:Connect(PanMenuItemFunction)
GameGui.OnClientEvent:Connect(MainMenuScreenInit)
ArrowLeft.MouseButton1Down:Connect(MouseClickLeft)
ArrowRight.MouseButton1Down:Connect(MouseClickRight)

Just finished making that change, anything else you would suggest?

Replace all the wait()'s with task.wait() since wait() is subject to throttling.

I know you already have a ton of variables but if you’re having this many functions in a single script might as well make it a separate modulescript

especially if you’re planning to use function aliases like what you did with mouseclickleft() and mouseclickright()

thats the big picture stuff though, ill trust other people to review the smaller stuff within the functions (which you should declare as local functions)

Done

--[Get Game Services]
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--[Get Player Variables]
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

--[Get Required Modules]
local FadeModule = require(ReplicatedStorage.Module.FadeModule)
local TypeWriteModule = require(ReplicatedStorage.Module.TypeWrite)
local IconSpriteData = require(ReplicatedStorage.IconSpriteData)

--[Get MainMeny Variables]
local MainMenuGui = ReplicatedStorage.Guis:WaitForChild("MainMenu")
local Background = MainMenuGui:WaitForChild("Background")
local TopCaption = MainMenuGui:WaitForChild("TopCaption")
local ExitTag = MainMenuGui:WaitForChild("ExitTag")
local MenuID = MainMenuGui:WaitForChild("ID")
local MenuItems = MainMenuGui:WaitForChild("MenuItems")
local MenuLabel = MainMenuGui:WaitForChild("MenuLabel")

--[Get MainMenuID Variables]
local Data = MenuID:WaitForChild("Data")
local DataLabels = Data:WaitForChild("Labels")
local FightIcons = MenuID:WaitForChild("FightIcons")
local PlayerIcon = MenuID:WaitForChild("Icon")

--[Get MainMenuItems Variables]
local ItemContainer = MenuItems:WaitForChild("Container")
--[Item Table]
local ItemTable = {
	Continue = ItemContainer["1-Continue"],
	ChangeNames = ItemContainer["2-Change Names"],
	DeleteSave = ItemContainer["3-Delete Save"],
	Help = ItemContainer["4-Help"],
	Jukebox = ItemContainer["5-Jukebox"],
	Settings = ItemContainer["6-Settings"]
}
--[Other MainMenuItems Variables]
local ArrowLeft = MenuItems:WaitForChild("ArrowLeft")
local ArrowRight = MenuItems:WaitForChild("ArrowRight")
local UIPageLayout = ItemContainer:WaitForChild("UIPageLayout")

--[Other Required Variables]
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local GameGui = ReplicatedStorage.Remote:WaitForChild("GameGui")
local FadeScreen = ReplicatedStorage.Remote:WaitForChild("FadeScreen")
local DataValues = ReplicatedStorage:WaitForChild("DataValues")
local PlayerData = DataValues:WaitForChild("PlayerData")
local cam = workspace.CurrentCamera

--[Set Up Variables]
Background.ImageTransparency = 1
TopCaption.Position = UDim2.new(-1, 0, 0, 0)
MenuID.Position = UDim2.new(0, 0, -1, 0)
MenuItems.Position = UDim2.new(0, 0, 1, 0)
for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end
for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
	Object.TextTransparency = 1
	Object.UIStroke.Transparency = 1
end

--[Gui Debug Boolean]
local GuiEnabled = false

--[Function List]
local function RefreshMenuItems()
	DataLabels._Name.Text = (PlayerData.PlayerName.Value)
	DataLabels.Team.Text = (PlayerData.TeamName.Value)
	DataLabels.Chapter.Text = (PlayerData.Chapter.Value)
	DataLabels.PlayTime.Text = (DataValues.PlayTime.Value)
	PlayerIcon.Image = IconSpriteData.SpriteIcons[PlayerData.Player.Value]
end

local function ChangeItemColor(Object)
	Object.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	Object.BackgroundTransparency = 0.5
	Object.ImageTransparency = 0.4
	Object.UIStroke.Thickness = 3
	Object.UIStroke.Color = Color3.new(0.258824, 0.258824, 0.258824)
end

local function DebugItems()
	for i, Object in pairs(ItemTable) do
		ChangeItemColor(Object)
	end
end

local function HighlightCurrentItem()
	UIPageLayout.CurrentPage.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
	UIPageLayout.CurrentPage.BackgroundTransparency = 0
	UIPageLayout.CurrentPage.ImageTransparency = 0
	UIPageLayout.CurrentPage.UIStroke.Thickness = 6
	UIPageLayout.CurrentPage.UIStroke.Color = Color3.new(1, 1, 1)
end

local function ChangePageLeft()
	DebugItems()
	UIPageLayout:Previous()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowLeft.Position = UDim2.new(0.391, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowLeft:TweenPosition(UDim2.new(0.401, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

local function ChangePageRight()
	DebugItems()
	UIPageLayout:Next()
	Sounds.Gui.SmallBlip.PlaybackSpeed = 1.2
	Sounds.Gui.SmallBlip:Play()
	ArrowRight.Position = UDim2.new(0.570, 0, 0.048, 0)
	MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
	MenuLabel.TextTransparency = 1
	MenuLabel.UIStroke.Transparency = 1
	MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
	HighlightCurrentItem()
	FadeModule:FadeText(MenuLabel, 0, 0.2)
	FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
	ArrowRight:TweenPosition(UDim2.new(0.559, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
end

local function PanItemsIn()
	RefreshMenuItems()
	GuiEnabled = true
	MenuID.Position = UDim2.new(0, 0, -1, 0)
	MenuItems.Position = UDim2.new(0, 0, 1, 0)
	MenuID:TweenPosition(UDim2.new(0, 0, 0.112, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 0.614, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true)
	task.wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		task.wait(0.025)
	end
	task.wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 0, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 0, 0.15)
		task.wait(0.025)
	end
	FadeModule:FadeText(ExitTag, 0, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 0, 0.3)
end

local function PanItemsOut()
	MenuID.Position = UDim2.new(0, 0, 0.112, 0)
	MenuItems.Position = UDim2.new(0, 0, 0.614, 0)
	FadeModule:FadeText(ExitTag, 1, 0.3)
	FadeModule:FadeStroke(ExitTag.UIStroke, 1, 0.3)
	task.wait()
	MenuID:TweenPosition(UDim2.new(0, 0, -1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	MenuItems:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1, true)
	TopCaption:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 0.5, true)
	task.wait(0.025)
	for i, Object in pairs(MenuID.Data.Labels:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		task.wait(0.025)
	end
	task.wait(0.015)
	for i, Object in pairs(MenuID.Data.Captions:GetChildren()) do
		FadeModule:FadeText(Object, 1, 0.15)
		FadeModule:FadeStroke(Object.UIStroke, 1, 0.15)
		task.wait(0.025)
	end
end

local function PanMenuItemFunction(Gui, Direction)
	if Gui == "Main Menu Items" then
		if Direction == "In" then
			PanItemsIn()
		elseif Direction == "Out" then
			PanItemsOut()
		else
		end
	else
		--Do Nothing
	end
end

local function MainMenuScreenInit(Gui)
	if Gui == "Main Menu" then
		GuiEnabled = true
		MenuLabel.Text = ""
		MainMenuGui.Parent = PlayerGui
		RefreshMenuItems()
		FadeModule:FadeImage(Background, 0, 1)
		Sounds.OST["2: Main Menu"]:Play()
		Sounds.OST["2: Main Menu"].Volume = 1
		task.wait(1)
		DebugItems()
		HighlightCurrentItem()
		PanItemsIn()
		MenuLabel.Position = UDim2.new(0.342, 0,0.637, 0)
		MenuLabel.TextTransparency = 1
		MenuLabel.UIStroke.Transparency = 1
		MenuLabel.Text = UIPageLayout.CurrentPage.UIname.Value
		FadeModule:FadeText(MenuLabel, 0, 0.2)
		FadeModule:FadeStroke(MenuLabel.UIStroke, 0, 0.2)
		MenuLabel:TweenPosition(UDim2.new(0.342, 0, 0.531, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.2, true)
	else
		--Do Nothing
	end
end

local function MouseClickLeft()
	ChangePageLeft()
end

local function MouseClickRight()
	ChangePageRight()
end

--[UserInputService]
UserInputService.InputBegan:Connect(function(InputObject)
	if GuiEnabled then
		if InputObject.KeyCode == Enum.KeyCode.Left then
			ChangePageLeft()
		end

		if InputObject.KeyCode == Enum.KeyCode.Right then
			ChangePageRight()
		end

		if InputObject.KeyCode == Enum.KeyCode.Space then
			GuiEnabled = false
			if UIPageLayout.CurrentPage.UIname.Value == "Continue" then
				print("Continue")
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				FadeModule:FadeAudio(Sounds.OST["3: Main Menu"], 0, 1)
				task.wait(1)
				FadeScreen:FireServer(2)
				task.wait(1)
				cam.CameraType = Enum.CameraType.Custom
				MainMenuGui.Parent = game:GetService("ReplicatedStorage"):WaitForChild("Guis")
			else
				Sounds.Gui.MainMenuSelect:Play()
				MenuLabel.Text = ""
				PanItemsOut()
				GameGui:FireServer(UIPageLayout.CurrentPage.UIname.Value)
			end
		end
	else
		--Do Nothing
	end
end)

--[Function Calls]
GameGui.OnClientEvent:Connect(PanMenuItemFunction)
GameGui.OnClientEvent:Connect(MainMenuScreenInit)
ArrowLeft.MouseButton1Down:Connect(MouseClickLeft)
ArrowRight.MouseButton1Down:Connect(MouseClickRight)