RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Make a leaderboard script for Workspace And leave notes in the script"
-- server script -- This script will create a leaderboard in Workspace. -- The leaderboard will be sorted by the player's Coins value. -- Get the leaderstats service local leaderstats = game:GetService("Leaderstats") -- Get the players local players = game:GetService("Players") -- Create the leaderboard local leaderboard = Instance.new("Folder", workspace) leaderboard.Name = "Leaderboard" -- Create a loop that will run every 10 seconds while true do -- Get a list of all the players local playerList = players:GetPlayers() -- Sort the list by the player's Coins value table.sort(playerList, function(player1, player2) return player1.leaderstats.Coins.Value > player2.leaderstats.Coins.Value end) -- Empty the leaderboard for i, child in ipairs(leaderboard:GetChildren()) do child:Destroy() end -- Create a label for each player in the leaderboard for i, player in ipairs(playerList) do local label = Instance.new("StringValue", leaderboard) label.Name = player.Name label.Value = player.leaderstats.Coins.Value end -- Wait 10 seconds before looping again wait(10) end