-- Leaderboard V2 Compact
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local GuiService = game:GetService("GuiService")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
---
-- CORE
pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end)
---
-- GUI
local Gui = Instance.new("ScreenGui")
Gui.Name = "LeaderboardV2"
Gui.ResetOnSpawn = false
Gui.IgnoreGuiInset = true
Gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
Gui.Parent = PlayerGui
---
-- TOGGLE
local Toggle = Instance.new("TextButton")
Toggle.Name = "Toggle"
Toggle.Size = UDim2.fromOffset(28, 42)
Toggle.Position = UDim2.new(1, -28, 0, 18)
Toggle.BackgroundColor3 = Color3.fromRGB(15, 15, 19)
Toggle.BackgroundTransparency = 0.12
Toggle.BorderSizePixel = 0
Toggle.Text = "<"
Toggle.TextColor3 = Color3.fromRGB(230, 230, 235)
Toggle.TextSize = 18
Toggle.Font = Enum.Font.GothamBold
Toggle.ZIndex = 100
Toggle.Parent = Gui
local ToggleCorner = Instance.new("UICorner")
ToggleCorner.CornerRadius = UDim.new(0, 8)
ToggleCorner.Parent = Toggle
local ToggleStroke = Instance.new("UIStroke")
ToggleStroke.Color = Color3.fromRGB(100, 70, 140)
ToggleStroke.Transparency = 0.6
ToggleStroke.Parent = Toggle
---
-- LEADERBOARD
local Main = Instance.new("Frame")
Main.Name = "Leaderboard"
Main.Size = UDim2.fromOffset(225, 205)
Main.Position = UDim2.new(1, -255, 0, 18)
Main.BackgroundColor3 = Color3.fromRGB(12, 12, 15)
Main.BackgroundTransparency = 0.18
Main.BorderSizePixel = 0
Main.Parent = Gui
local MainCorner = Instance.new("UICorner")
MainCorner.CornerRadius = UDim.new(0, 10)
MainCorner.Parent = Main
local MainStroke = Instance.new("UIStroke")
MainStroke.Color = Color3.fromRGB(100, 70, 140)
MainStroke.Transparency = 0.7
MainStroke.Parent = Main
---
-- HEADER
local Title = Instance.new("TextLabel")
Title.Size = UDim2.new(1, -65, 0, 30)
Title.Position = UDim2.fromOffset(9, 3)
Title.BackgroundTransparency = 1
Title.Text = "PLAYERS"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 15
Title.Font = Enum.Font.GothamBold
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.Parent = Main
local Count = Instance.new("TextLabel")
Count.Size = UDim2.fromOffset(55, 25)
Count.Position = UDim2.new(1, -62, 0, 5)
Count.BackgroundTransparency = 1
Count.TextColor3 = Color3.fromRGB(150, 150, 160)
Count.TextSize = 10
Count.Font = Enum.Font.GothamMedium
Count.TextXAlignment = Enum.TextXAlignment.Right
Count.Parent = Main
local Line = Instance.new("Frame")
Line.Size = UDim2.new(1, -16, 0, 1)
Line.Position = UDim2.fromOffset(8, 32)
Line.BackgroundColor3 = Color3.fromRGB(70, 70, 75)
Line.BackgroundTransparency = 0.45
Line.BorderSizePixel = 0
Line.Parent = Main
---
-- PLAYER LIST
local List = Instance.new("ScrollingFrame")
List.Name = "PlayerList"
List.Size = UDim2.new(1, -10, 1, -39)
List.Position = UDim2.fromOffset(5, 37)
List.BackgroundTransparency = 1
List.BorderSizePixel = 0
List.ScrollBarThickness = 2
List.ScrollBarImageColor3 = Color3.fromRGB(160, 80, 255)
List.AutomaticCanvasSize = Enum.AutomaticSize.Y
List.CanvasSize = UDim2.new()
List.Parent = Main
local Layout = Instance.new("UIListLayout")
Layout.Padding = UDim.new(0, 3)
Layout.SortOrder = Enum.SortOrder.LayoutOrder
Layout.Parent = List
local Padding = Instance.new("UIPadding")
Padding.PaddingLeft = UDim.new(0, 2)
Padding.PaddingRight = UDim.new(0, 2)
Padding.PaddingBottom = UDim.new(0, 3)
Padding.Parent = List
---
-- VARIABLES
local SelectedPlayer = nil
local Profile = nil
local Spectating = false
local Open = true
---
-- TOGGLE
Toggle.Activated:Connect(function()
Open = not Open
Main.Visible = Open
if Open then
Toggle.Text = "<"
Toggle.Position = UDim2.new(1, -28, 0, 18)
else
Toggle.Text = ">"
Toggle.Position = UDim2.new(1, -28, 0, 18)
end
end)
---
-- FRIEND
local function isFriend(player)
if player == LocalPlayer then
return false
end
local success, result = pcall(function()
return LocalPlayer:IsFriendsWith(player.UserId)
end)
return success and result == true
end
---
-- STAT
local function getStat(player)
local stats = player:FindFirstChild("leaderstats")
if not stats then
return nil
end
local values = stats:GetChildren()
if #values == 0 then
return nil
end
table.sort(values, function(a, b)
return a.Name < b.Name
end)
return values[1]
end
---
-- STOP SPECTATE
local function stopSpectating()
Spectating = false
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
local character = LocalPlayer.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if humanoid then
camera.CameraSubject = humanoid
end
end
---
-- DESTROY PROFILE
local function destroyProfile()
stopSpectating()
if Profile then
Profile:Destroy()
Profile = nil
end
SelectedPlayer = nil
end
---
-- BUTTON
local function createButton(parent, text)
local Button = Instance.new("TextButton")
Button.Size = UDim2.new(1, 0, 0, 27)
Button.BackgroundColor3 = Color3.fromRGB(30, 30, 36)
Button.BackgroundTransparency = 0.1
Button.BorderSizePixel = 0
Button.Text = text
Button.TextColor3 = Color3.fromRGB(240, 240, 245)
Button.TextSize = 12
Button.Font = Enum.Font.GothamMedium
Button.ZIndex = 30
Button.Parent = parent
local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 6)
Corner.Parent = Button
return Button
end
---
-- REPORT
local function openReportPanel(target)
local ReportGui = Instance.new("Frame")
ReportGui.Name = "ReportPanel"
ReportGui.Size = UDim2.fromOffset(220, 135)
ReportGui.Position = UDim2.fromScale(0.5, 0.5)
ReportGui.AnchorPoint = Vector2.new(0.5, 0.5)
ReportGui.BackgroundColor3 = Color3.fromRGB(15, 15, 19)
ReportGui.BackgroundTransparency = 0.08
ReportGui.BorderSizePixel = 0
ReportGui.ZIndex = 100
ReportGui.Parent = Gui
local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 10)
Corner.Parent = ReportGui
local Title = Instance.new("TextLabel")
Title.Size = UDim2.new(1, -16, 0, 25)
Title.Position = UDim2.fromOffset(8, 7)
Title.BackgroundTransparency = 1
Title.Text = "Report " .. target.DisplayName
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 14
Title.Font = Enum.Font.GothamBold
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.ZIndex = 101
Title.Parent = ReportGui
local Info = Instance.new("TextLabel")
Info.Size = UDim2.new(1, -16, 0, 40)
Info.Position = UDim2.fromOffset(8, 35)
Info.BackgroundTransparency = 1
Info.Text = "Use Roblox's official report system."
Info.TextColor3 = Color3.fromRGB(175, 175, 185)
Info.TextSize = 10
Info.Font = Enum.Font.Gotham
Info.TextWrapped = true
Info.ZIndex = 101
Info.Parent = ReportGui
local Close = createButton(ReportGui, "Close")
Close.Size = UDim2.fromOffset(80, 27)
Close.Position = UDim2.new(0.5, -40, 1, -34)
Close.ZIndex = 101
Close.Activated:Connect(function()
ReportGui:Destroy()
end)
end
---
-- OPEN PROFILE
local function openProfile(player, row)
if SelectedPlayer == player and Profile then
destroyProfile()
return
end
destroyProfile()
SelectedPlayer = player
Profile = Instance.new("Frame")
Profile.Name = "PlayerProfile"
Profile.Size = UDim2.fromOffset(180, 285)
Profile.BackgroundColor3 = Color3.fromRGB(15, 15, 19)
Profile.BackgroundTransparency = 0.14
Profile.BorderSizePixel = 0
Profile.ZIndex = 20
Profile.Parent = Gui
local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 10)
Corner.Parent = Profile
local Stroke = Instance.new("UIStroke")
Stroke.Color = Color3.fromRGB(100, 70, 140)
Stroke.Transparency = 0.65
Stroke.Parent = Profile
--------------------------------------------------
-- POSITION
--------------------------------------------------
local viewport = workspace.CurrentCamera.ViewportSize
local x = Main.AbsolutePosition.X - 188
if x < 5 then
x = Main.AbsolutePosition.X + Main.AbsoluteSize.X + 6
end
local y = math.clamp(
row.AbsolutePosition.Y,
5,
viewport.Y - 290
)
Profile.Position = UDim2.fromOffset(x, y)
--------------------------------------------------
-- TITLE
--------------------------------------------------
local Header = Instance.new("TextLabel")
Header.Size = UDim2.new(1, -40, 0, 23)
Header.Position = UDim2.fromOffset(8, 4)
Header.BackgroundTransparency = 1
Header.Text = "PLAYER"
Header.TextColor3 = Color3.fromRGB(255, 255, 255)
Header.TextSize = 14
Header.Font = Enum.Font.GothamBold
Header.TextXAlignment = Enum.TextXAlignment.Left
Header.ZIndex = 21
Header.Parent = Profile
--------------------------------------------------
-- CLOSE
--------------------------------------------------
local Close = Instance.new("TextButton")
Close.Size = UDim2.fromOffset(21, 21)
Close.Position = UDim2.new(1, -27, 0, 5)
Close.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
Close.BackgroundTransparency = 0.1
Close.BorderSizePixel = 0
Close.Text = "×"
Close.TextColor3 = Color3.fromRGB(220, 220, 225)
Close.TextSize = 15
Close.Font = Enum.Font.GothamBold
Close.ZIndex = 35
Close.Parent = Profile
local CloseCorner = Instance.new("UICorner")
CloseCorner.CornerRadius = UDim.new(1, 0)
CloseCorner.Parent = Close
Close.Activated:Connect(destroyProfile)
--------------------------------------------------
-- AVATAR
--------------------------------------------------
local Avatar = Instance.new("ImageLabel")
Avatar.Size = UDim2.fromOffset(43, 43)
Avatar.Position = UDim2.fromOffset(8, 31)
Avatar.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
Avatar.BorderSizePixel = 0
Avatar.ZIndex = 21
Avatar.Parent = Profile
local AvatarCorner = Instance.new("UICorner")
AvatarCorner.CornerRadius = UDim.new(1, 0)
AvatarCorner.Parent = Avatar
task.spawn(function()
local success, image = pcall(function()
return Players:GetUserThumbnailAsync(
player.UserId,
Enum.ThumbnailType.HeadShot,
Enum.ThumbnailSize.Size100x100
)
end)
if success and Avatar.Parent then
Avatar.Image = image
end
end)
--------------------------------------------------
-- NAME
--------------------------------------------------
local DisplayName = Instance.new("TextLabel")
DisplayName.Size = UDim2.new(1, -62, 0, 19)
DisplayName.Position = UDim2.fromOffset(59, 32)
DisplayName.BackgroundTransparency = 1
DisplayName.Text = player.DisplayName
DisplayName.TextColor3 = Color3.fromRGB(215, 155, 255)
DisplayName.TextSize = 13
DisplayName.Font = Enum.Font.GothamBold
DisplayName.TextXAlignment = Enum.TextXAlignment.Left
DisplayName.TextTruncate = Enum.TextTruncate.AtEnd
DisplayName.ZIndex = 21
DisplayName.Parent = Profile
local Username = Instance.new("TextLabel")
Username.Size = UDim2.new(1, -62, 0, 16)
Username.Position = UDim2.fromOffset(59, 51)
Username.BackgroundTransparency = 1
Username.Text = "@" .. player.Name
Username.TextColor3 = Color3.fromRGB(145, 145, 155)
Username.TextSize = 10
Username.Font = Enum.Font.Gotham
Username.TextXAlignment = Enum.TextXAlignment.Left
Username.TextTruncate = Enum.TextTruncate.AtEnd
Username.ZIndex = 21
Username.Parent = Profile
--------------------------------------------------
-- ID
--------------------------------------------------
local ID = Instance.new("TextLabel")
ID.Size = UDim2.new(1, -16, 0, 17)
ID.Position = UDim2.fromOffset(8, 77)
ID.BackgroundTransparency = 1
ID.Text = "ID: " .. player.UserId
ID.TextColor3 = Color3.fromRGB(120, 120, 130)
ID.TextSize = 10
ID.Font = Enum.Font.Gotham
ID.TextXAlignment = Enum.TextXAlignment.Left
ID.ZIndex = 21
ID.Parent = Profile
--------------------------------------------------
-- BUTTONS
--------------------------------------------------
local Buttons = Instance.new("Frame")
Buttons.Size = UDim2.new(1, -16, 0, 174)
Buttons.Position = UDim2.fromOffset(8, 99)
Buttons.BackgroundTransparency = 1
Buttons.ZIndex = 21
Buttons.Parent = Profile
local ButtonLayout = Instance.new("UIListLayout")
ButtonLayout.Padding = UDim.new(0, 3)
ButtonLayout.Parent = Buttons
--------------------------------------------------
-- ADD FRIEND
--------------------------------------------------
local AddFriend = createButton(Buttons, "Add Friend")
AddFriend.Activated:Connect(function()
local target = SelectedPlayer
if not target or target == LocalPlayer then
return
end
pcall(function()
StarterGui:SetCore("PromptSendFriendRequest", target)
end)
end)
--------------------------------------------------
-- EXAMINE
--------------------------------------------------
local Examine = createButton(Buttons, "Examine")
Examine.Activated:Connect(function()
local target = SelectedPlayer
if not target then
return
end
pcall(function()
GuiService:InspectPlayerFromUserId(target.UserId)
end)
end)
--------------------------------------------------
-- BLOCK
--------------------------------------------------
local Block = createButton(Buttons, "Block")
Block.Activated:Connect(function()
local target = SelectedPlayer
if not target or target == LocalPlayer then
return
end
pcall(function()
StarterGui:SetCore("PromptBlockPlayer", target)
end)
end)
--------------------------------------------------
-- REPORT
--------------------------------------------------
local Report = createButton(Buttons, "Report")
Report.Activated:Connect(function()
local target = SelectedPlayer
if target then
openReportPanel(target)
end
end)
--------------------------------------------------
-- GOTO
--------------------------------------------------
local Goto = createButton(Buttons, "Goto")
Goto.Activated:Connect(function()
local target = SelectedPlayer
if not target then
return
end
local character = LocalPlayer.Character
local targetCharacter = target.Character
if not character or not targetCharacter then
return
end
local root = character:FindFirstChild("HumanoidRootPart")
local targetRoot = targetCharacter:FindFirstChild("HumanoidRootPart")
if root and targetRoot then
root.CFrame = targetRoot.CFrame * CFrame.new(3, 0, 0)
end
end)
--------------------------------------------------
-- SPECTATE
--------------------------------------------------
local Spectate = createButton(Buttons, "Spectate")
Spectate.Activated:Connect(function()
local target = SelectedPlayer
if not target then
return
end
if Spectating then
stopSpectating()
Spectate.Text = "Spectate"
return
end
local character = target.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if not humanoid then
return
end
Spectating = true
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = humanoid
Spectate.Text = "Stop Spectating"
end)
end
---
-- CREATE ROW
local function createRow(player, position)
local Row = Instance.new("TextButton")
Row.Name = player.Name
Row.Size = UDim2.new(1, 0, 0, 38)
Row.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
Row.BackgroundTransparency = 0.08
Row.BorderSizePixel = 0
Row.Text = ""
Row.AutoButtonColor = false
Row.LayoutOrder = position
Row.Parent = List
local Corner = Instance.new("UICorner")
Corner.CornerRadius = UDim.new(0, 7)
Corner.Parent = Row
--------------------------------------------------
-- FRIEND COLOR
--------------------------------------------------
if player == LocalPlayer then
Row.BackgroundColor3 = Color3.fromRGB(35, 25, 50)
elseif isFriend(player) then
Row.BackgroundColor3 = Color3.fromRGB(255, 246, 190)
end
--------------------------------------------------
-- RANK
--------------------------------------------------
local Rank = Instance.new("TextLabel")
Rank.Size = UDim2.fromOffset(22, 38)
Rank.Position = UDim2.fromOffset(2, 0)
Rank.BackgroundTransparency = 1
Rank.Text = "#" .. position
Rank.TextSize = 9
Rank.Font = Enum.Font.GothamBold
Rank.Parent = Row
if player == LocalPlayer then
Rank.TextColor3 = Color3.fromRGB(200, 130, 255)
elseif isFriend(player) then
Rank.TextColor3 = Color3.fromRGB(160, 135, 60)
else
Rank.TextColor3 = Color3.fromRGB(135, 135, 145)
end
--------------------------------------------------
-- AVATAR
--------------------------------------------------
local Avatar = Instance.new("ImageLabel")
Avatar.Size = UDim2.fromOffset(29, 29)
Avatar.Position = UDim2.fromOffset(28, 4)
Avatar.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
Avatar.BorderSizePixel = 0
Avatar.Parent = Row
local AvatarCorner = Instance.new("UICorner")
AvatarCorner.CornerRadius = UDim.new(1, 0)
AvatarCorner.Parent = Avatar
task.spawn(function()
local success, image = pcall(function()
return Players:GetUserThumbnailAsync(
player.UserId,
Enum.ThumbnailType.HeadShot,
Enum.ThumbnailSize.Size100x100
)
end)
if success and Avatar.Parent then
Avatar.Image = image
end
end)
--------------------------------------------------
-- NAME
--------------------------------------------------
local Name = Instance.new("TextLabel")
Name.Size = UDim2.new(1, -105, 0, 18)
Name.Position = UDim2.fromOffset(62, 1)
Name.BackgroundTransparency = 1
Name.Text = player.DisplayName
Name.TextSize = 11
Name.Font = Enum.Font.GothamBold
Name.TextXAlignment = Enum.TextXAlignment.Left
Name.TextTruncate = Enum.TextTruncate.AtEnd
Name.Parent = Row
if player == LocalPlayer then
Name.TextColor3 = Color3.fromRGB(210, 145, 255)
elseif isFriend(player) then
Name.TextColor3 = Color3.fromRGB(110, 85, 25)
else
Name.TextColor3 = Color3.fromRGB(245, 245, 245)
end
--------------------------------------------------
-- USERNAME
--------------------------------------------------
local Username = Instance.new("TextLabel")
Username.Size = UDim2.new(1, -105, 0, 14)
Username.Position = UDim2.fromOffset(62, 19)
Username.BackgroundTransparency = 1
Username.Text = "@" .. player.Name
Username.TextColor3 = Color3.fromRGB(125, 125, 135)
Username.TextSize = 8
Username.Font = Enum.Font.Gotham
Username.TextXAlignment = Enum.TextXAlignment.Left
Username.TextTruncate = Enum.TextTruncate.AtEnd
Username.Parent = Row
--------------------------------------------------
-- STAT
--------------------------------------------------
local Stat = getStat(player)
local Value = Instance.new("TextLabel")
Value.Size = UDim2.fromOffset(42, 38)
Value.Position = UDim2.new(1, -47, 0, 0)
Value.BackgroundTransparency = 1
Value.Text = Stat and tostring(Stat.Value) or "-"
Value.TextColor3 = Color3.fromRGB(190, 125, 255)
Value.TextSize = 10
Value.Font = Enum.Font.GothamBold
Value.TextXAlignment = Enum.TextXAlignment.Right
Value.Parent = Row
--------------------------------------------------
-- SELECT
--------------------------------------------------
Row.Activated:Connect(function()
openProfile(player, Row)
end)
end
---
-- REFRESH
local function refreshLeaderboard()
for _, object in ipairs(List:GetChildren()) do
if object:IsA("TextButton") then
object:Destroy()
end
end
local playerList = Players:GetPlayers()
table.sort(playerList, function(a, b)
local statA = getStat(a)
local statB = getStat(b)
if statA and statB
and typeof(statA.Value) == "number"
and typeof(statB.Value) == "number" then
return statA.Value > statB.Value
end
return a.Name:lower() < b.Name:lower()
end)
for i, player in ipairs(playerList) do
createRow(player, i)
end
Count.Text = #playerList .. "/" .. Players.MaxPlayers
end
---
-- UPDATE STAT
local function updatePlayerValue(player)
local row = List:FindFirstChild(player.Name)
if not row then
return
end
local stat = getStat(player)
if not stat then
return
end
for _, object in ipairs(row:GetChildren()) do
if object:IsA("TextLabel")
and object.Position == UDim2.new(1, -47, 0, 0) then
object.Text = tostring(stat.Value)
end
end
end
---
-- WATCH STATS
local function watchStats(player)
local function connectStats()
local stats = player:FindFirstChild("leaderstats")
if not stats then
return
end
for _, value in ipairs(stats:GetChildren()) do
if value:IsA("ValueBase") then
value.Changed:Connect(function()
updatePlayerValue(player)
end)
end
end
stats.ChildAdded:Connect(function(value)
if value:IsA("ValueBase") then
value.Changed:Connect(function()
updatePlayerValue(player)
end)
end
end)
end
if player:FindFirstChild("leaderstats") then
connectStats()
end
player.ChildAdded:Connect(function(child)
if child.Name == "leaderstats" then
task.defer(connectStats)
end
end)
end
---
-- PLAYER EVENTS
Players.PlayerAdded:Connect(function(player)
refreshLeaderboard()
watchStats(player)
end)
Players.PlayerRemoving:Connect(function(player)
if SelectedPlayer == player then
destroyProfile()
end
refreshLeaderboard()
end)
for _, player in ipairs(Players:GetPlayers()) do
watchStats(player)
end
---
-- START
refreshLeaderboard()