– Corey, Site-02.
– Main Menu Handler
– Services & Variables
local ms = game:GetService(“MarketplaceService”)
local repStor = game:GetService(“ReplicatedStorage”)
local guiEvents = repStor.GUIs
local plr = game.Players.LocalPlayer
local selectedTeam = “N/A”
local mainMenuUI = script.Parent.Holder
local buttons = script.Parent.Holder.Buttons
local menus = script.Parent.Holder.Menus
local playButton = buttons:FindFirstChild(“1Play”)
local teamButton = buttons:FindFirstChild(“2Team”)
local settingsButton = buttons:FindFirstChild(“3Settings”)
local storeButton = buttons:FindFirstChild(“4Store”)
local creditsButton = buttons:FindFirstChild(“5Credits”)
local teamChangeMenu = menus.TeamChange
local teams = teamChangeMenu.Teams
local teamLabel = teamChangeMenu.currentTeam
local storeMenu = menus.Store
local gamepassInfo = storeMenu.GamepassInfo
local settingsMenu = menus.Settings
local creditsMenu = menus.Credits
– Main Code
– Add play button.
script.Parent.Enabled = true
function hitPlay()
if selectedTeam == “N/A” then
mainMenuUI.SelectTeam.Visible = true
wait(5)
mainMenuUI.SelectTeam.Visible = false
elseif selectedTeam ~= “N/A” then
guiEvents.TeamChange:FireServer(plr, selectedTeam)
guiEvents.ReloadChar:FireServer(plr)
script.Parent.Enabled = false
end
end
function menuTeams()
closeMenus()
teamChangeMenu.Visible = true
if plr.leaderstats.XP.Value >= 50 then
teams.SD.Locked.Visible = false
teams.SD.Active = true
end
end
function teamCD()
selectedTeam = BrickColor.new(“Deep orange”)
updateTeamLabel()
end
function teamSD()
selectedTeam = BrickColor.new(“Dark stone grey”)
updateTeamLabel()
end
function closeMenus()
teamChangeMenu.Visible = false
storeMenu.Visible = false
settingsMenu.Visible = false
creditsMenu.Visible = false
end
function menuCredits()
closeMenus()
creditsMenu.Visible = true
end
function menuSettings()
closeMenus()
settingsMenu.Visible = true
end
function menuStore()
closeMenus()
storeMenu.Visible = true
end
function infoDoubleXP()
gamepassInfo.DoubleXP.Visible = true
end
function closeDoubleXP()
gamepassInfo.DoubleXP.Visible = false
end
function buyDoubleXP()
ms:PromptGamePassPurchase(plr, 23819722)
end
function updateTeamLabel()
if selectedTeam == BrickColor.new(“Deep orange”) then
teamLabel.Text = “Current Team Selected: Class-D”
elseif selectedTeam == BrickColor.new(“Dark stone grey”) then
teamLabel.Text = “Current Team Selected: Security Department”
end
end
– Triggers
playButton.MouseButton1Click:Connect(hitPlay)
teams.SD.MouseButton1Click:Connect(teamSD)
teams.CD.MouseButton1Click:Connect(teamCD)
teamButton.MouseButton1Click:Connect(menuTeams)
settingsButton.MouseButton1Click:Connect(menuSettings)
creditsButton.MouseButton1Click:Connect(menuCredits)
storeButton.MouseButton1Click:Connect(menuStore)
storeMenu.DoubleXP.Purchase.MouseButton1Click:Connect(infoDoubleXP)
gamepassInfo.DoubleXP.Back.MouseButton1Click:Connect(closeDoubleXP)
gamepassInfo.DoubleXP.Purchase.MouseButton1Click:Connect(buyDoubleXP)