Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How can I fix this custom leaderboard script?

Asked by
j5707r -36
6 years ago
Edited 6 years ago
local repStorage = game:GetService("ReplicatedStorage")
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
local PLACE_OWNER_ICON = "rbxasset://textures/ui/icon_placeowner.png"
local ROYALTY_ICON = "rbxassetid://0"
local BC_ICON = "rbxasset://textures/ui/icon_BC-16.png"
local TBC_ICON = "rbxasset://textures/ui/icon_TBC-16.png"
local OBC_ICON = "rbxasset://textures/ui/icon_OBC-16.png"
local BLOCKED_ICON = "rbxasset://textures/ui/PlayerList/BlockedIcon.png"
local HR_ICON = "http://www.roblox.com/asset/?id=0"
local DL_ICON = "http://www.roblox.com/asset/?id=0"
local WK_ICON = "http://www.roblox.com/asset/?id=0"
local TD_ICON = "http://www.roblox.com/asset/?id=0"
local PC_ICON = "http://www.roblox.com/asset/?id=0"
local UserInput = game:GetService("UserInputService")
local ROYALTY = {
  ["1"] = true
}
local CUSTOM_ICON = {
  ["0"] = {
    "http://www.roblox.com/asset/?id=0"
  },
  ["0"] = {
    "http://www.roblox.com/asset/?id=0"
  }
}
local label = script.playerLabel
local playerLI = script.PlayerList
game.Players.PlayerAdded:connect(function(plr)
  plr.Changed:connect(function(val)
    if val == "TeamColor" then
      reloadList()
    end
  end)
  reloadList()
end)
game.Players.ChildRemoved:connect(function()
  reloadList()
end)
local prev
function reloadList()
  if script.Parent.Screen:FindFirstChild("PlayerList") then
    script.Parent.Screen.PlayerList:Destroy()
  end
  local playerList = playerLI:Clone()
  playerList.Parent = script.Parent.Screen
  playerList.CanvasSize = UDim2.new(0, 0, 0, 0)
  local count = 1
  for _, team in pairs(game.Teams:GetChildren()) do
    if playerList then
      makeLabel(count, team.Name, false, team.TeamColor.Color, 18, playerList)
      count = count + 1
      for i, v in pairs(game.Players:GetChildren()) do
        while playerList do
          if v.TeamColor == team.TeamColor then
            do
              local plrIcon = playerIcon(v)
              makeLabel(count, v.Name, plrIcon, Color3.new(0, 0, 0), 25, playerList)
              count = count + 1
            end
            break
          else
            else
              break
            end
          end
        end
      end
  end
  prev = nil
end
function makeLabel(number, name, icon, color, size, pl)
  if pl then
    local newTag = label:Clone()
    newTag.PName.Text = name
    if icon == false and pl then
      newTag.Icon:Destroy()
      newTag.PName.Position = UDim2.new(0, 1, 0, 0)
    else
      newTag.Icon.Image = icon
    end
    if name == "Test" then
      newTag.PName.TextColor3 = Color3.new(1, 0, 1)
    end
    newTag.Size = UDim2.new(0, 176, 0, size)
    newTag.PName.Size = UDim2.new(0, 146, 0, size)
    newTag.BackgroundColor3 = color
    if prev == nil and pl then
      newTag.Position = UDim2.new(0, 0, 0, (size + 1) * (number - 1))
      pl.CanvasSize = UDim2.new(0, 0, 0, (size + 1) * number)
    else
      newTag.Position = UDim2.new(0, 0, 0, prev.Position.Y.Offset + 1 + prev.Size.Y.Offset)
      pl.CanvasSize = UDim2.new(0, 0, 0, prev.Position.Y.Offset + 1 + (prev.Size.Y.Offset + size))
    end
    newTag.Parent = pl
    prev = newTag
  end
end
function playerIcon(player)
  local membershipType = player.MembershipType
  local idSTR = tostring(player.userId)
  if CUSTOM_ICON[idSTR] then
    return CUSTOM_ICON[idSTR][1]
  end
  if ROYALTY[tostring(player.userId)] ~= nil then
    return ROYALTY_ICON
  end
  if player:GetRankInGroup(0) == 0 then
    return DL_ICON
  elseif player:GetRankInGroup(0) >= 0 then
    return PC_ICON
  elseif player:GetRankInGroup(0) >= 0 then
    return HR_ICON
  elseif 1 <= player:GetRankInGroup(0) then
    return WK_ICON
  elseif game.CreatorId == player.userId then
    return PLACE_OWNER_ICON
  elseif membershipType == Enum.MembershipType.BuildersClub then
    return BC_ICON
  elseif membershipType == Enum.MembershipType.TurboBuildersClub then
    return TBC_ICON
  elseif membershipType == Enum.MembershipType.OutrageousBuildersClub then
    return OBC_ICON
  else
    return "http://www.roblox.com/asset/?id=00"
  end
end
game.Players.LocalPlayer.Changed:connect(function()
  reloadList()
end)
local KeyUp = function(Input, Process)
  if not Process and Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.Tab then
    if script.Parent.Screen.Visible == false then
      script.Parent.Screen.Visible = true
    else
      script.Parent.Screen.Visible = false
    end
  end
end
UserInput.InputBegan:connect(KeyUp)
wait(3)
reloadList()

I am trying to make a custom leaderboard where certain group ranks get logos on the side of their names. I tried this script, but it did not work. It was a localscript in Startergui with a screengui as it's parent.

0
Are you getting any errors? What is the result? Also are there any other objects in the ScreenGui and script that you didn’t tell us? User#20279 0 — 6y
0
No j5707r -36 — 6y

Answer this question