| |
|
| |
|
| | local Players = game:GetService("Players")
|
| | local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
| |
|
| | local GameConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("GameConfig"))
|
| |
|
| |
|
| | local leaderboardFolder = Instance.new("Folder")
|
| | leaderboardFolder.Name = "Leaderboard"
|
| | leaderboardFolder.Parent = workspace
|
| |
|
| | local function createLeaderboardDisplay()
|
| | local board = Instance.new("Part")
|
| | board.Name = "LeaderboardBoard"
|
| | board.Size = Vector3.new(12, 8, 0.5)
|
| | board.Position = Vector3.new(-10, 8, -80)
|
| | board.Anchored = true
|
| | board.Material = Enum.Material.SmoothPlastic
|
| | board.BrickColor = BrickColor.new("Really black")
|
| | board.Parent = leaderboardFolder
|
| |
|
| | local surfaceGui = Instance.new("SurfaceGui")
|
| | surfaceGui.Name = "LeaderboardGui"
|
| | surfaceGui.Face = Enum.NormalId.Front
|
| | surfaceGui.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
|
| | surfaceGui.PixelsPerStud = 50
|
| | surfaceGui.Parent = board
|
| |
|
| |
|
| | local title = Instance.new("TextLabel")
|
| | title.Name = "Title"
|
| | title.Size = UDim2.new(1, 0, 0.15, 0)
|
| | title.Position = UDim2.new(0, 0, 0, 0)
|
| | title.BackgroundColor3 = Color3.fromRGB(40, 80, 40)
|
| | title.BorderSizePixel = 0
|
| | title.Text = "TOP LUMBERJACKS"
|
| | title.TextColor3 = Color3.new(1, 1, 1)
|
| | title.TextScaled = true
|
| | title.Font = Enum.Font.GothamBold
|
| | title.Parent = surfaceGui
|
| |
|
| |
|
| | local entriesFrame = Instance.new("Frame")
|
| | entriesFrame.Name = "Entries"
|
| | entriesFrame.Size = UDim2.new(1, 0, 0.85, 0)
|
| | entriesFrame.Position = UDim2.new(0, 0, 0.15, 0)
|
| | entriesFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
|
| | entriesFrame.BorderSizePixel = 0
|
| | entriesFrame.Parent = surfaceGui
|
| |
|
| | local listLayout = Instance.new("UIListLayout")
|
| | listLayout.SortOrder = Enum.SortOrder.LayoutOrder
|
| | listLayout.Parent = entriesFrame
|
| |
|
| | return entriesFrame
|
| | end
|
| |
|
| | local entriesFrame = createLeaderboardDisplay()
|
| |
|
| | local function updateLeaderboard()
|
| |
|
| | for _, child in pairs(entriesFrame:GetChildren()) do
|
| | if child:IsA("TextLabel") then
|
| | child:Destroy()
|
| | end
|
| | end
|
| |
|
| |
|
| | local playerStats = {}
|
| | for _, player in ipairs(Players:GetPlayers()) do
|
| | local leaderstats = player:FindFirstChild("leaderstats")
|
| | if leaderstats then
|
| | local cash = leaderstats:FindFirstChild("Cash")
|
| | if cash then
|
| | table.insert(playerStats, {
|
| | name = player.Name,
|
| | cash = cash.Value,
|
| | })
|
| | end
|
| | end
|
| | end
|
| |
|
| |
|
| | table.sort(playerStats, function(a, b) return a.cash > b.cash end)
|
| |
|
| |
|
| | local maxEntries = math.min(#playerStats, 10)
|
| | for i = 1, maxEntries do
|
| | local entry = Instance.new("TextLabel")
|
| | entry.Name = "Entry_" .. i
|
| | entry.Size = UDim2.new(1, 0, 0, 30)
|
| | entry.LayoutOrder = i
|
| | entry.BackgroundTransparency = 0.5
|
| | entry.BackgroundColor3 = i % 2 == 0 and Color3.fromRGB(30, 30, 30) or Color3.fromRGB(40, 40, 40)
|
| | entry.BorderSizePixel = 0
|
| | entry.Text = string.format(" #%d %s - $%s", i, playerStats[i].name, tostring(playerStats[i].cash))
|
| | entry.TextColor3 = i == 1 and Color3.fromRGB(255, 215, 0) or Color3.new(1, 1, 1)
|
| | entry.TextXAlignment = Enum.TextXAlignment.Left
|
| | entry.TextScaled = true
|
| | entry.Font = Enum.Font.GothamMedium
|
| | entry.Parent = entriesFrame
|
| | end
|
| | end
|
| |
|
| |
|
| | task.spawn(function()
|
| | while true do
|
| | updateLeaderboard()
|
| | task.wait(15)
|
| | end
|
| | end)
|
| |
|
| | print("Leaderboard Manager initialized")
|
| |
|