Advertisement
Guest User

Leaderboard+ Plugin Source Code

a guest
Jul 8th, 2021
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.09 KB | None | 0 0
  1. --Sorry in advance for the mess. The newer versions have been updated with better and more organized code.
  2.  
  3. local ChangeHistoryService = game:GetService("ChangeHistoryService")
  4.  
  5. local toolbar = plugin:CreateToolbar("Custom Leaderboards")
  6.  
  7. local ToolbarButton = toolbar:CreateButton("Leaderboard+", "Make Custom Leaderboards", "rbxassetid://7059608654")
  8. local Opened = false
  9.  
  10.  
  11. local LeaderboardInfo = DockWidgetPluginGuiInfo.new(
  12.     Enum.InitialDockState.Left,
  13.     false,   -- Widget will be initially enabled
  14.     false,  -- Don't override the previous enabled state
  15.     220,    -- Default width of the floating window
  16.     300,    -- Default height of the floating window
  17.     220,    -- Minimum width of the floating window (optional)
  18.     300     -- Minimum height of the floating window (optional)
  19. )
  20.  
  21. local PluginWidget = plugin:CreateDockWidgetPluginGui("Leaderboard+", LeaderboardInfo)
  22. PluginWidget.Title = "Leaderboard+ Settings"
  23.  
  24. --[[Variables for the Leaderboard Interface]]
  25. local MainGui = script.Parent.LeaderboardInterface.MainFrame:Clone()
  26. MainGui.Parent = PluginWidget
  27.  
  28. local MainButtons = MainGui.Holder.MainButtons
  29. local ColorPicker = MainGui.Holder.ColorPicker
  30. local BackgroundColorButton = MainButtons.BackgroundColorButton
  31. local GenerateButton = MainButtons.Generate
  32. local Path = MainButtons.Path
  33. local CustomDataToggle = MainButtons.CustomData.Toggle
  34. local ShowPremiumToggle = MainButtons.ShowPremium.Toggle
  35. local Textbox1 = ColorPicker.RGBInput.Blue.TextBox
  36. local Textbox2  = ColorPicker.RGBInput.Green.TextBox
  37. local Textbox3 =  ColorPicker.RGBInput.Red.TextBox
  38. local ChosenColor = MainGui.ChosenColor
  39. local DisplayFrame = ColorPicker.Display
  40. local NewLeaderboard = nil
  41.  
  42. --[[Handle Clicks]]
  43. ToolbarButton.Click:Connect(function()
  44.     PluginWidget.Enabled = not PluginWidget.Enabled
  45.     NewLeaderboard = nil
  46.     NewLeaderboard = script.Parent.CustomLeaderboard:Clone()
  47. end)
  48.  
  49. BackgroundColorButton.MouseButton1Click:Connect(function()
  50.     MainButtons.Visible = false
  51.     ColorPicker.Visible = true
  52. end)
  53.  
  54. ColorPicker.Finish.MouseButton1Click:Connect(function()
  55.     MainButtons.Visible = true
  56.     ColorPicker.Visible = false
  57. end)
  58.  
  59. GenerateButton.MouseButton1Click:Connect(function()
  60.     if game.StarterGui:FindFirstChild("CustomLeaderboard") then
  61.         game.StarterGui:FindFirstChild("CustomLeaderboard"):Destroy()
  62.     end
  63.     NewLeaderboard.LeaderboardFrame.BackgroundColor3 = ChosenColor.Value
  64.     NewLeaderboard.LeaderboardHandler.Disabled = false
  65.     NewLeaderboard.LocalHandler.Disabled = false
  66.     if NewLeaderboard.Settings.CustomData.Value == true then
  67.         NewLeaderboard.LeaderboardFrame.HoldingFrame.Sample.Currency1.Visible = true
  68.         NewLeaderboard.LeaderboardFrame.TitleCurrency.Visible = true
  69.     end
  70.     local PathText = "script.Parent.Settings.CustomData"
  71.  
  72.     if Path.Text ~= " " and Path.Text ~= nil and Path.Text ~= "" then
  73.         PathText = Path.Text
  74.     end
  75.     local LeaderboardScript = NewLeaderboard.LeaderboardHandler
  76.    
  77.     LeaderboardScript.Source = [[
  78. --Custom Leaderboard Script. Made by Leaderboard+ plugin (by Infinite_Visions).
  79. --Find the plugin here: https://www.roblox.com/library/7066294774/Leaderboard
  80.  
  81. local Path = nil
  82.  
  83. --Setup Players Already In-Game
  84. for i, player in pairs(game.Players:GetChildren()) do
  85.     --Add a slot to the leaderboard
  86.     local NewSlot = script.Parent.LeaderboardFrame.HoldingFrame.Sample:Clone()
  87.     NewSlot.Name = player.Name
  88.     NewSlot.PlrName.Text = player.Name
  89.     if player.MembershipType == Enum.MembershipType.Premium then
  90.         if script.Parent.Settings.ShowPremium.Value == true then
  91.             NewSlot.Premium.Visible = true
  92.         end
  93.     end
  94.     NewSlot.Visible = true
  95.     --The Path to the Values you want displayed, if any.
  96.     if script.Parent.Settings.CustomData.Value == true then
  97.         Path = ]] ..PathText..[[
  98.        
  99.         Path.Changed:Connect(function()
  100.             NewSlot.Currency1.Text = Path.Value
  101.         end)
  102.     end
  103.     NewSlot.Parent = script.Parent.LeaderboardFrame.HoldingFrame
  104. end
  105.  
  106. game.Players.PlayerAdded:Connect(function(player)
  107. --Add a slot to the leaderboard
  108.     local NewSlot = script.Parent.LeaderboardFrame.HoldingFrame.Sample:Clone()
  109.     NewSlot.Name = player.Name
  110.     NewSlot.PlrName.Text = player.Name
  111.     if player.MembershipType == Enum.MembershipType.Premium then
  112.         if script.Parent.Settings.ShowPremium.Value == true then
  113.             NewSlot.Premium.Visible = true
  114.         end
  115.     end
  116.     NewSlot.Visible = true
  117.     --The Path to the Values you want displayed, if any.
  118.     if script.Parent.Settings.CustomData.Value == true then
  119.         Path = ]] ..PathText..[[
  120.        
  121.         Path.Changed:Connect(function()
  122.             NewSlot.Currency1.Text = Path.Value
  123.         end)
  124.     end
  125.     NewSlot.Parent = script.Parent.LeaderboardFrame.HoldingFrame
  126. end)
  127. ]]
  128.     NewLeaderboard.Parent = game.StarterGui
  129. end)
  130.  
  131. CustomDataToggle.MouseButton1Click:Connect(function()
  132.     if CustomDataToggle.Text == "✔" then
  133.         CustomDataToggle.Parent.BackgroundColor3 = Color3.fromRGB(79, 79, 79)
  134.         CustomDataToggle.BackgroundColor3 = Color3.fromRGB(99, 16, 0)
  135.         NewLeaderboard.Settings.CustomData.Value = false
  136.         CustomDataToggle.Text = "❌"
  137.         Path.BackgroundColor3 = Color3.fromRGB(79, 79, 79)
  138.     else
  139.         CustomDataToggle.Parent.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  140.         NewLeaderboard.Settings.CustomData.Value = true
  141.         CustomDataToggle.BackgroundColor3 = Color3.fromRGB(48, 156, 9)
  142.         Path.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  143.         CustomDataToggle.Text = "✔"
  144.     end
  145. end)
  146.  
  147. ShowPremiumToggle.MouseButton1Click:Connect(function()
  148.     if ShowPremiumToggle.Text == "✔" then
  149.         ShowPremiumToggle.Parent.BackgroundColor3 = Color3.fromRGB(79, 79, 79)
  150.         NewLeaderboard.Settings.ShowPremium.Value = false
  151.         ShowPremiumToggle.BackgroundColor3 = Color3.fromRGB(99, 16, 0)
  152.         ShowPremiumToggle.Text = "❌"
  153.     else
  154.         ShowPremiumToggle.Parent.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  155.         NewLeaderboard.Settings.ShowPremium.Value = true
  156.         ShowPremiumToggle.BackgroundColor3 = Color3.fromRGB(48, 156, 9)
  157.         ShowPremiumToggle.Text = "✔"
  158.     end
  159. end)
  160.  
  161. --[[Handle Background Color]]
  162. local R = 0
  163. local G = 0
  164. local B = 0
  165.  
  166. Textbox1:GetPropertyChangedSignal("Text"):Connect(function()
  167.     Textbox1.Text = Textbox1.Text:gsub('%D+', '');
  168.     if Textbox1.Text == " " or Textbox1.Text == nil then
  169.         B = 0
  170.     else
  171.         B = tonumber(Textbox1.Text)
  172.     end
  173.     ChosenColor.Value = Color3.fromRGB(R,G,B)
  174.     DisplayFrame.BackgroundColor3 = Color3.fromRGB(R,G,B)
  175.     NewLeaderboard.LeaderboardFrame.Close.BackgroundColor3 = Color3.fromRGB(R,G,B)
  176.  
  177. end)
  178.  
  179. Textbox2:GetPropertyChangedSignal("Text"):Connect(function()
  180.     Textbox2.Text = Textbox2.Text:gsub('%D+', '');
  181.     if Textbox2.Text == " " or Textbox2.Text == nil then
  182.         G = 0
  183.     else
  184.         G = tonumber(Textbox2.Text)
  185.     end
  186.     ChosenColor.Value = Color3.fromRGB(R,G,B)
  187.  
  188.     DisplayFrame.BackgroundColor3 = Color3.fromRGB(R,G,B)
  189.     NewLeaderboard.LeaderboardFrame.Close.BackgroundColor3 = Color3.fromRGB(R,G,B)
  190. end)
  191.  
  192. Textbox3:GetPropertyChangedSignal("Text"):Connect(function()
  193.     Textbox3.Text = Textbox3.Text:gsub('%D+', '');
  194.     if Textbox3.Text == " " or Textbox3.Text == nil then
  195.         R = 0
  196.     else
  197.         R = tonumber(Textbox3.Text)
  198.     end
  199.     ChosenColor.Value = Color3.fromRGB(R,G,B)
  200.  
  201.     DisplayFrame.BackgroundColor3 = Color3.fromRGB(R,G,B)
  202.     NewLeaderboard.LeaderboardFrame.Close.BackgroundColor3 = Color3.fromRGB(R,G,B)
  203. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement