Advertisement
9_cVv

ui lib test

Mar 26th, 2021 (edited)
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.56 KB | None | 0 0
  1. local sectionlibrary = {}
  2.    function sectionlibrary:CreateSection(sectionName)
  3.     local uilibrary = Instance.new("ScreenGui")
  4.     local sections = Instance.new("Frame")
  5.     local template = Instance.new("ImageLabel")
  6.     local top = Instance.new("ImageLabel")
  7.     local shadow = Instance.new("Frame")
  8.     local shadowgradiant = Instance.new("UIGradient")
  9.     local title = Instance.new("TextLabel")
  10.     local grad = Instance.new("UIGradient")
  11.     local main = Instance.new("Frame")
  12.     local buttonTemplate = Instance.new("TextButton")
  13.     local UIListLayout = Instance.new("UIListLayout")
  14.     local labelTemplate = Instance.new("TextLabel")
  15.     local boxTemplate = Instance.new("TextBox")
  16.     local dropdownTemplate = Instance.new("TextButton")
  17.     local openClose = Instance.new("TextButton")
  18.     local dropdown = Instance.new("Frame")
  19.  
  20.     uilibrary.Name = "~~<[{(uilibrary)}]>~~"
  21.     uilibrary.Parent = game:GetService'CoreGui'
  22.     pcall(function() syn.protect_gui(uilibrary) end)
  23.     uilibrary.ResetOnSpawn = false
  24.  
  25.     sections.Name = "sections"
  26.     sections.Parent = uilibrary
  27.     sections.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  28.     sections.BackgroundTransparency = 1.000
  29.     sections.BorderSizePixel = 0
  30.     sections.Position = UDim2.new(0.0127272531, 0, 0.0109223304, 0)
  31.     sections.Size = UDim2.new(0, 1086, 0, 265)
  32.  
  33.     template.Name = "template"
  34.     template.Parent = sections
  35.     template.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  36.     template.BackgroundTransparency = 1.000
  37.     template.Position = UDim2.new(0, 50, 0, 0)
  38.     template.Size = UDim2.new(0, 177, 0, 266)
  39.     template.Visible = false
  40.     template.Image = "rbxassetid://3570695787"
  41.     template.ScaleType = Enum.ScaleType.Slice
  42.     template.SliceCenter = Rect.new(100, 100, 100, 100)
  43.     template.SliceScale = 0.060
  44.     _G.SECTION = template
  45.  
  46.     top.Name = "top"
  47.     top.Parent = template
  48.     top.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  49.     top.BackgroundTransparency = 1.000
  50.     top.Position = UDim2.new(-6.85788279e-07, 0, 0, 0)
  51.     top.Size = UDim2.new(0, 177, 0, 25)
  52.     top.Image = "rbxassetid://3570695787"
  53.     top.ImageColor3 = Color3.fromRGB(44, 44, 44)
  54.     top.ScaleType = Enum.ScaleType.Slice
  55.     top.SliceCenter = Rect.new(100, 100, 100, 100)
  56.     top.SliceScale = 0.060
  57.  
  58.     shadow.Name = "shadow"
  59.     shadow.Parent = top
  60.     shadow.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  61.     shadow.BorderSizePixel = 0
  62.     shadow.Position = UDim2.new(1.37157656e-06, 0, 0.680000007, 0)
  63.     shadow.Size = UDim2.new(0, 177, 0, 16)
  64.  
  65.     shadowgradiant.Color = ColorSequence.new{ColorSequenceKeypoint.new(0.00, Color3.fromRGB(44, 44, 44)), ColorSequenceKeypoint.new(1.00, Color3.fromRGB(56, 56, 56))}
  66.     shadowgradiant.Rotation = 90
  67.     shadowgradiant.Name = "shadowgradiant"
  68.     shadowgradiant.Parent = shadow
  69.  
  70.     title.Name = "title"
  71.     title.Parent = top
  72.     title.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  73.     title.BackgroundTransparency = 1.000
  74.     title.BorderSizePixel = 0
  75.     title.Position = UDim2.new(1.37157656e-06, 0, 0, 0)
  76.     title.Size = UDim2.new(0, 177, 0, 25)
  77.     title.Font = Enum.Font.Gotham
  78.     title.Text = "TechHub"
  79.     title.TextColor3 = Color3.fromRGB(255, 255, 255)
  80.     title.TextSize = 20.000
  81.     title.TextWrapped = true
  82.  
  83.     grad.Color = ColorSequence.new{ColorSequenceKeypoint.new(0.00, Color3.fromRGB(44, 44, 44)), ColorSequenceKeypoint.new(1.00, Color3.fromRGB(56, 56, 56))}
  84.     grad.Rotation = 270
  85.     grad.Name = "grad"
  86.     grad.Parent = template
  87.  
  88.     main.Name = "main"
  89.     main.Parent = template
  90.     main.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  91.     main.BackgroundTransparency = 1.000
  92.     main.BorderSizePixel = 0
  93.     main.Position = UDim2.new(0, 0, 0.0950185061, 0)
  94.     main.Size = UDim2.new(0, 177, 0, 240)
  95.  
  96.     buttonTemplate.Name = "buttonTemplate"
  97.     buttonTemplate.Parent = main
  98.     buttonTemplate.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  99.     buttonTemplate.BackgroundTransparency = 1.000
  100.     buttonTemplate.BorderSizePixel = 0
  101.     buttonTemplate.Position = UDim2.new(0.0112997796, 0, -0.0156301036, 0)
  102.     buttonTemplate.Size = UDim2.new(0, 176, 0, 22)
  103.     buttonTemplate.Visible = false
  104.     buttonTemplate.Font = Enum.Font.Gotham
  105.     buttonTemplate.Text = "button"
  106.     buttonTemplate.TextColor3 = Color3.fromRGB(255, 255, 255)
  107.     buttonTemplate.TextScaled = true
  108.     buttonTemplate.TextSize = 14.000
  109.     buttonTemplate.TextWrapped = true
  110.  
  111.     UIListLayout.Parent = main
  112.     UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  113.  
  114.     labelTemplate.Name = "labelTemplate"
  115.     labelTemplate.Parent = main
  116.     labelTemplate.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  117.     labelTemplate.BackgroundTransparency = 1.000
  118.     labelTemplate.BorderSizePixel = 0
  119.     labelTemplate.Position = UDim2.new(0.00564971752, 0, 0.0509259254, 0)
  120.     labelTemplate.Size = UDim2.new(0, 176, 0, 22)
  121.     labelTemplate.Visible = false
  122.     labelTemplate.Font = Enum.Font.Gotham
  123.     labelTemplate.Text = "label"
  124.     labelTemplate.TextColor3 = Color3.fromRGB(255, 255, 255)
  125.     labelTemplate.TextScaled = true
  126.     labelTemplate.TextSize = 14.000
  127.     labelTemplate.TextWrapped = true
  128.  
  129.     boxTemplate.Name = "boxTemplate"
  130.     boxTemplate.Parent = main
  131.     boxTemplate.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  132.     boxTemplate.BackgroundTransparency = 1.000
  133.     boxTemplate.BorderSizePixel = 0
  134.     boxTemplate.Position = UDim2.new(0.00564971752, 0, -0.0509259254, 0)
  135.     boxTemplate.Size = UDim2.new(0, 176, 0, 22)
  136.     boxTemplate.Visible = false
  137.     boxTemplate.Font = Enum.Font.Gotham
  138.     boxTemplate.PlaceholderColor3 = Color3.fromRGB(255, 255, 255)
  139.     boxTemplate.PlaceholderText = "box"
  140.     boxTemplate.Text = ""
  141.     boxTemplate.TextColor3 = Color3.fromRGB(255, 255, 255)
  142.     boxTemplate.TextScaled = true
  143.     boxTemplate.TextSize = 18.000
  144.     boxTemplate.TextWrapped = true
  145.  
  146.     dropdownTemplate.Name = "dropdownTemplate"
  147.     dropdownTemplate.Parent = main
  148.     dropdownTemplate.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  149.     dropdownTemplate.BackgroundTransparency = 1.000
  150.     dropdownTemplate.BorderSizePixel = 0
  151.     dropdownTemplate.Position = UDim2.new(0.0112997796, 0, -0.0156301036, 0)
  152.     dropdownTemplate.Size = UDim2.new(0, 176, 0, 22)
  153.     dropdownTemplate.Visible = false
  154.     dropdownTemplate.Font = Enum.Font.Gotham
  155.     dropdownTemplate.Text = "dropdown"
  156.     dropdownTemplate.TextColor3 = Color3.fromRGB(255, 255, 255)
  157.     dropdownTemplate.TextScaled = true
  158.     dropdownTemplate.TextSize = 14.000
  159.     dropdownTemplate.TextWrapped = true
  160.     dropdownTemplate.TextXAlignment = Enum.TextXAlignment.Left
  161.  
  162.     openClose.Name = "openClose"
  163.     openClose.Parent = dropdownTemplate
  164.     openClose.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  165.     openClose.BackgroundTransparency = 1.000
  166.     openClose.BorderSizePixel = 0
  167.     openClose.Position = UDim2.new(0.880681813, 0, 0, 0)
  168.     openClose.Rotation = 180.000
  169.     openClose.Size = UDim2.new(0, 22, 0, 22)
  170.     openClose.Font = Enum.Font.Code
  171.     openClose.Text = "^"
  172.     openClose.TextColor3 = Color3.fromRGB(255, 255, 255)
  173.     openClose.TextScaled = true
  174.     openClose.TextSize = 14.000
  175.     openClose.TextWrapped = true
  176.     openClose.TextYAlignment = Enum.TextYAlignment.Bottom
  177.  
  178.     dropdown.Name = "dropdown"
  179.     dropdown.Parent = dropdownTemplate
  180.     dropdown.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  181.     dropdown.BackgroundTransparency = 1.000
  182.     dropdown.BorderSizePixel = 0
  183.     dropdown.Position = UDim2.new(-0.00568181835, 0, 1, 0)
  184.     dropdown.Size = UDim2.new(0, 177, 0, 218)
  185.  
  186.     if not tonumber(_G.SECTIONS) then _G.SECTIONS = 0 end
  187.     _G.SECTIONS = _G.SECTIONS + 1
  188.     repeat wait() until _G.SECTION
  189.     local section = _G.SECTION:Clone()
  190.     section.Parent = _G.SECTION.Parent
  191.     section.Position = UDim2.new(-0.18, _G.SECTIONS  * 200, 0, 0)
  192.     section.Name = sectionName
  193.     section.Visible = true
  194.     section.Active = true section.Draggable = true
  195.     section.top.title.Text = sectionName
  196.  
  197.     local tween = game:GetService("TweenService")
  198.     local ishover = false
  199.  
  200.     section.MouseLeave:Connect(function()
  201.         ishover = false
  202.         tween:Create(section, TweenInfo.new(.5), {ImageTransparency=.65}):Play()
  203.         tween:Create(section.top, TweenInfo.new(.5), {ImageTransparency=.65}):Play()
  204.         for a,b in pairs(section['main']:GetChildren()) do
  205.             if b:IsA("TextButton") or b:IsA("TextLabel") or b:IsA("TextBox") then
  206.                 tween:Create(b, TweenInfo.new(.5), {TextTransparency=.65}):Play()
  207.             end
  208.         end
  209.         for a,b in pairs(section.top:GetChildren()) do
  210.             if b:IsA("Frame") then
  211.                 tween:Create(b, TweenInfo.new(.5), {BackgroundTransparency=.65}):Play()
  212.             end
  213.             if b:IsA("TextLabel") then
  214.                 tween:Create(b, TweenInfo.new(.5), {TextTransparency=.65}):Play()
  215.             end
  216.         end
  217.     end)
  218.     section.MouseEnter:Connect(function()
  219.         ishover = true
  220.         tween:Create(section, TweenInfo.new(.5), {ImageTransparency=0}):Play()
  221.         tween:Create(section.top, TweenInfo.new(.5), {ImageTransparency=0}):Play()
  222.         for a,b in pairs(section['main']:GetChildren()) do
  223.             if b:IsA("TextButton") or b:IsA("TextLabel") or b:IsA("TextBox") then
  224.                 tween:Create(b, TweenInfo.new(.5), {TextTransparency=0}):Play()
  225.             end
  226.         end
  227.         for a,b in pairs(section.top:GetChildren()) do
  228.             if b:IsA("Frame") then
  229.                 tween:Create(b, TweenInfo.new(.5), {BackgroundTransparency=0}):Play()
  230.             end
  231.             if b:IsA("TextLabel") then
  232.                 tween:Create(b, TweenInfo.new(.5), {TextTransparency=0}):Play()
  233.             end
  234.         end
  235.     end)
  236.  
  237.     local objectlibrary = {}
  238.     function objectlibrary:CreateButton(buttonName)
  239.         local button = section.main.buttonTemplate:Clone()
  240.         button.Parent = section.main
  241.         button.Name = buttonName
  242.         button.Text = buttonName
  243.         button.Visible = true
  244.  
  245.         return button
  246.     end
  247.     function objectlibrary:CreateLabel(labelName)
  248.         local label = section.main.labelTemplate:Clone()
  249.         label.Parent = section.main
  250.         label.Name = labelName
  251.         label.Text = labelName
  252.         label.Visible = true
  253.  
  254.         return label
  255.     end
  256.     function objectlibrary:CreateBox(boxName)
  257.         local box = section.main.boxTemplate:Clone()
  258.         box.Parent = section.main
  259.         box.Name = boxName
  260.         box.Text = ''
  261.         box.PlaceholderText = boxName
  262.         box.Visible = true
  263.  
  264.         return box
  265.     end
  266.     function objectlibrary:CreateDropdown(dropdownName, size, buttons)
  267.         local open = false
  268.         local button = section.main.dropdownTemplate:Clone()
  269.         button.Parent = section.main
  270.         button.Name = dropdownName
  271.         button.Text = dropdownName
  272.         button.Visible = true
  273.  
  274.         button.dropdown.Visible = false
  275.         local sizeX = size.X.Offset
  276.         local sizeY = size.Y.Offset
  277.         local ddSize = button.dropdown.Size
  278.  
  279.         ddSize = UDim2.new(0, sizeX, 0, 0)
  280.  
  281.         local openTween = tween:Create(button.dropdown, TweenInfo.new(.3), {Size=size})
  282.         local closeTween = tween:Create(button.dropdown, TweeinInfo.new(.3), {Size=UDim2.new(0, sizeX, 0, 0)})
  283.         button.openClose.MouseButton1Click:connect(function()
  284.             open = not open
  285.             if open == true then
  286.                 button.openClose.Rotation = 0
  287.                 button.dropdown.Visible = true
  288.                 --[[for a,b in pairs(button.dropdown:GetDescendants()) do
  289.                     local a,h = pcall(function()
  290.                         if b['Visible'] then
  291.                             return true
  292.                         else
  293.                             return false
  294.                         end
  295.                     end)
  296.                     if h == true then
  297.                         b.Visible = true
  298.                     end
  299.                 end]]
  300.                 openTween:Play()
  301.                 closeTween:Cancel()
  302.             elseif open == false then
  303.                 button.openClose.Rotation = 180
  304.                 closeTween:Play()
  305.                 openTween:Cancel()
  306.                 wait(.3)
  307.                 if open == false then
  308.                     button.dropdown.Visible = true
  309.                     --[[for a,b in pairs(button.dropdown:GetDescendants()) do
  310.                         local a,h = pcall(function()
  311.                             if b['Visible'] then
  312.                                 return true
  313.                             else
  314.                                 return false
  315.                             end
  316.                         end)
  317.                         if h == true then
  318.                             b.Visible = false
  319.                         end
  320.                     end]]
  321.                 end
  322.             end
  323.         end)
  324.         local _buttons
  325.         if typeof(buttons) == 'table' then _buttons = buttons else _buttons = {buttons} end
  326.         for a,b in pairs(_buttons) do
  327.             local clone = button.dropdown.dropdownTemplate:Clone()
  328.             clone.Parent = button.dropdown
  329.             clone.Visible = open
  330.             b:Destroy()
  331.         end
  332.         return button
  333.     end
  334.     return objectlibrary
  335. end
  336. return sectionlibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement