how can i improve my ui script for an fps game, the script isnt fully finished yet
---- [Menu] ----
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
--
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
--
local UI = PlayerGui:WaitForChild("HubUI")
local Sounds = UI:WaitForChild("Sounds")
----
print("Loading Menu Module")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
----
do
local SelectedTopButton = "Play"
local function InvisiblePageSelections()
for _, Page in pairs(UI.Pages:GetChildren()) do
Page.Visible = false
end
UI.GameModes.Visible = false
end
----
-- Gamemode Selection
for _, Mode in pairs(UI.GameModes:GetChildren()) do
-- Mouse Enter
Mode.MouseEnter:Connect(function()
Mode.Label.TextColor3 = Color3.fromRGB(212, 170, 50)
Sounds.Hover:Play()
end)
-- Mouse Leave
Mode.MouseLeave:Connect(function()
Mode.Label.TextColor3 = Color3.fromRGB(255, 255, 255)
end)
end
-- TopBar
for _, Button in pairs(UI.TopBar.Buttons:GetChildren()) do
if Button:IsA("TextButton") then
-- Mouse Enter
Button.MouseEnter:Connect(function()
Button.Label.TextColor3 = Color3.fromRGB(212, 170, 50)
Sounds.Hover:Play()
end)
-- Mouse Leave
Button.MouseLeave:Connect(function()
if SelectedTopButton ~= Button.Name then
Button.Label.TextColor3 = Color3.fromRGB(152, 152, 152)
end
end)
-- Left Click
Button.MouseButton1Click:Connect(function()
for _, b in pairs(UI.TopBar.Buttons:GetChildren()) do
b.Line.Visible = false
b.Label.TextColor3 = Color3.fromRGB(152, 152, 152)
end
Button.Line.Visible = true
Button.Label.TextColor3 = Color3.fromRGB(212, 170, 50)
SelectedTopButton = Button.Name
if Button.Name == "Play" then
InvisiblePageSelections()
UI.GameModes.Visible = true
else
print(Button.Name)
InvisiblePageSelections()
if UI.Pages:FindFirstChild(Button.Name) then
UI.Pages[Button.Name].Visible = true
end
end
end)
end
end
end
----
do
--- Pages
-- Weapons
for _, Button in pairs(UI.Pages.Weapons.Buttons:GetChildren()) do
-- Mouse Enter
Button.MouseEnter:Connect(function()
Button.Label.TextColor3 = Color3.fromRGB(212, 170, 50)
Sounds.Hover:Play()
end)
-- Mouse Leave
Button.MouseLeave:Connect(function()
Button.Label.TextColor3 = Color3.fromRGB(152, 152, 152)
end)
end
end