Advertisement
HowToRoblox

GuiHandler

Jan 29th, 2023
1,664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.56 KB | None | 0 0
  1. local badgeIds = {
  2.     1338151805,
  3.     1338152217,
  4.     1338152564,
  5.     1338152991,
  6.     1338153317,
  7.     1338162926,
  8.     1581974685,
  9.     2124476827,
  10.     2124647572,
  11.     2124684123,
  12.     2124769992,
  13.     2124769993,
  14.     2124769994,
  15.     2124769995,
  16.     2124773711,
  17.     2125759516,
  18.     2128847177,
  19.     2129021840,
  20.     2129021843,
  21.     2129745218,
  22.     2129745220,
  23. }
  24.  
  25. local openBtn = script.Parent:WaitForChild("OpenListButton")
  26. local badgeList = script.Parent:WaitForChild("BadgeListBackground")
  27. local closeBtn = badgeList:WaitForChild("CloseButton")
  28. local scrollingFrame = badgeList:WaitForChild("BadgeList")
  29.  
  30. local badgeTemplate = script:WaitForChild("Badge")
  31.  
  32. badgeList.Visible = false
  33.  
  34. openBtn.MouseButton1Click:Connect(function()
  35.     badgeList.Visible = not badgeList.Visible
  36. end)
  37.  
  38. closeBtn.MouseButton1Click:Connect(function()
  39.     badgeList.Visible = false
  40. end)
  41.  
  42.  
  43. local ts = game:GetService("TweenService")
  44. local ti = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
  45.  
  46. function buttonEffect(button)
  47.    
  48.     local originalSize = button.Size
  49.     local hoverSize = UDim2.new(originalSize.X.Scale * 1.05, originalSize.X.Offset * 1.05, originalSize.Y.Scale * 1.05, originalSize.Y.Offset * 1.05)
  50.     local clickSize = UDim2.new(originalSize.X.Scale * 0.95, originalSize.X.Offset * 0.95, originalSize.Y.Scale * 0.95, originalSize.Y.Offset * 0.95)
  51.    
  52.     local normalTween = ts:Create(button, ti, {Size = originalSize})
  53.     local hoverTween = ts:Create(button, ti, {Size = hoverSize})
  54.     local clickTween = ts:Create(button, ti, {Size = clickSize})
  55.    
  56.     local hovering = false
  57.    
  58.     button.MouseEnter:Connect(function()
  59.         hovering = true
  60.         hoverTween:Play()
  61.     end)
  62.     button.MouseLeave:Connect(function()
  63.         hovering = false
  64.         normalTween:Play()
  65.     end)
  66.     button.MouseButton1Down:Connect(function()
  67.         clickTween:Play()
  68.     end)
  69.     button.MouseButton1Up:Connect(function()
  70.         if hovering then
  71.             hoverTween:Play()
  72.         else
  73.             normalTween:Play()
  74.         end
  75.     end)
  76. end
  77.  
  78. buttonEffect(openBtn)
  79. buttonEffect(closeBtn)
  80.  
  81.  
  82. local badgeFrames = {}
  83. local badgeService = game:GetService("BadgeService")
  84.  
  85. function createGui()
  86.    
  87.     for _, child in pairs(scrollingFrame:GetChildren()) do
  88.         if child.ClassName == badgeTemplate.ClassName then
  89.             child:Destroy()
  90.         end
  91.     end
  92.     for _, badgeFrame in pairs(badgeFrames) do
  93.         badgeFrame:Destroy()
  94.     end
  95.     badgeFrames = {}
  96.    
  97.     for _, badgeId in pairs(badgeIds) do
  98.        
  99.         local badgeInfo = nil
  100.         local success, err = pcall(function()
  101.             badgeInfo = badgeService:GetBadgeInfoAsync(badgeId)
  102.         end)
  103.        
  104.         if success then
  105.            
  106.             local newFrame = badgeTemplate:Clone()
  107.             newFrame.Name = badgeId
  108.            
  109.             newFrame.BadgeImage.Image = "rbxassetid://" .. badgeInfo.IconImageId
  110.             newFrame.BadgeName.Text = badgeInfo.Name
  111.             newFrame.BadgeDescription.Text = badgeInfo.Description
  112.            
  113.             local userHasBadge = nil
  114.             success, err = pcall(function()
  115.                 userHasBadge = badgeService:UserHasBadgeAsync(game.Players.LocalPlayer.UserId, badgeId)
  116.             end)
  117.            
  118.             if userHasBadge then
  119.                 newFrame.ImageColor3 = Color3.fromRGB(255, 255, 255)
  120.             else
  121.                 newFrame.ImageColor3 = Color3.fromRGB(150, 150, 150)
  122.             end
  123.            
  124.             table.insert(badgeFrames, newFrame)
  125.         end
  126.     end
  127. end
  128.  
  129.  
  130. while true do
  131.    
  132.     if #badgeFrames ~= #badgeIds then
  133.         createGui()
  134.     end
  135.    
  136.     table.sort(badgeFrames, function(a, b)
  137.         return (a.ImageColor3.R > b.ImageColor3.R) or ((a.ImageColor3.R == b.ImageColor3.R) and (a.BadgeName.Text < b.BadgeName.Text))
  138.     end)
  139.    
  140.     for _, badgeFrame in pairs(badgeFrames) do
  141.         badgeFrame.Parent = script
  142.     end
  143.     for _, badgeFrame in pairs(badgeFrames) do
  144.         badgeFrame.Parent = scrollingFrame
  145.     end
  146.    
  147.     task.wait(15)
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement