Download src/ServerScriptService/LeaderboardManager.server.lua from algorembrant/TimberWoods: direct link, hf CLI and curl.
- Browser
- Download file 3.59 kB
-
https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/ServerScriptService/LeaderboardManager.server.lua
- Command line
-
hf download hf://algorembrant/TimberWoods/src/ServerScriptService/LeaderboardManager.server.lua
-
curl -L -o LeaderboardManager.server.lua https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/ServerScriptService/LeaderboardManager.server.lua
3.59 kB
| -- src/ServerScriptService/LeaderboardManager.server.lua | |
| local Players = game:GetService("Players") | |
| local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
| local GameConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("GameConfig")) | |
| -- Create global leaderboard SurfaceGui on a part in the world | |
| 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 | |
| -- Title | |
| 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 | |
| -- Entries container | |
| 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() | |
| -- Clear existing entries | |
| for _, child in pairs(entriesFrame:GetChildren()) do | |
| if child:IsA("TextLabel") then | |
| child:Destroy() | |
| end | |
| end | |
| -- Collect player data | |
| 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 | |
| -- Sort by cash descending | |
| table.sort(playerStats, function(a, b) return a.cash > b.cash end) | |
| -- Display top 10 | |
| 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 | |
| -- Update periodically | |
| task.spawn(function() | |
| while true do | |
| updateLeaderboard() | |
| task.wait(15) | |
| end | |
| end) | |
| print("Leaderboard Manager initialized") | |