Advertisement
joefromsansnite

UI Library

Dec 18th, 2022 (edited)
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.77 KB | None | 0 0
  1. local Library = {}
  2.  
  3. local tweenservice = game:GetService("TweenService")
  4.  
  5. local player: Player = game.Players.LocalPlayer
  6. local mouse: Mouse = player:GetMouse()
  7.  
  8. function dropdownFunction(dropdown: ImageButton, subject: Frame | {Frame}, status: boolean)
  9.     local rotation: number = status and 0 or 180
  10.     local tween: Tween = tweenservice:Create(dropdown, TweenInfo.new(.2), {Rotation = rotation})
  11.    
  12.     if typeof(subject) == "table" then
  13.         for _, subj: Frame in pairs(subject) do
  14.             subj.Visible = status
  15.         end
  16.     else
  17.         subject.Visible = status
  18.     end
  19.    
  20.     tween:Play()
  21. end
  22.  
  23. function Library:CreateWindow(ui_title: string)
  24.     local UILib = {}
  25.    
  26.     local UI = Instance.new("ScreenGui")
  27.     local Tabs = Instance.new("ImageLabel")
  28.     local UIListLayout_1 = Instance.new("UIListLayout")
  29.     local UIStroke_1 = Instance.new("UIStroke")
  30.     local Title = Instance.new("Frame")
  31.     local MainTitle = Instance.new("TextLabel")
  32.     local Exit = Instance.new("ImageButton")
  33.     local UIAspectRatioConstraint_1 = Instance.new("UIAspectRatioConstraint")
  34.     local Dropdown_1 = Instance.new("ImageButton")
  35.     local UIAspectRatioConstraint_2 = Instance.new("UIAspectRatioConstraint")
  36.     local UIStroke_2 = Instance.new("UIStroke")
  37.     local UICorner_1 = Instance.new("UICorner")
  38.     local UICorner_2 = Instance.new("UICorner")
  39.  
  40.     UI.Name = "UI"
  41.     UI.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  42.    
  43.     Tabs.Name = "Tabs"
  44.     Tabs.Parent = UI
  45.     Tabs.Active = true
  46.     Tabs.Draggable = true
  47.     Tabs.AnchorPoint = Vector2.new(0.5, 0.5)
  48.     Tabs.AutomaticSize = Enum.AutomaticSize.Y
  49.     Tabs.BorderColor3 = Color3.fromRGB(20,20,20)
  50.     Tabs.BorderSizePixel = 3
  51.     Tabs.Position = UDim2.new(0.5, 0,0.5, 0)
  52.     Tabs.Size = UDim2.new(0, 180,0, 0)
  53.     Tabs.Image = "rbxassetid://823352249"
  54.     Tabs.ImageColor3 = Color3.fromRGB(150,150,150)
  55.     Tabs.ScaleType = Enum.ScaleType.Crop
  56.  
  57.     UIListLayout_1.Parent = Tabs
  58.     UIListLayout_1.HorizontalAlignment = Enum.HorizontalAlignment.Center
  59.     UIListLayout_1.SortOrder = Enum.SortOrder.LayoutOrder
  60.    
  61.     UIStroke_1.Parent = Tabs
  62.     UIStroke_1.Color = Color3.fromRGB(40,40,40)
  63.     UIStroke_1.LineJoinMode = Enum.LineJoinMode.Miter
  64.     UIStroke_1.Thickness = 1
  65.  
  66.     Title.Name = "Title"
  67.     Title.Parent = Tabs
  68.     Title.BackgroundTransparency = 1
  69.     Title.Size = UDim2.new(1, 0,0, 20)
  70.    
  71.     MainTitle.Name = "Main"
  72.     MainTitle.Parent = Title
  73.     MainTitle.AnchorPoint = Vector2.new(0.5, 0.5)
  74.     MainTitle.BackgroundTransparency = 1
  75.     MainTitle.Position = UDim2.new(0.417, 0,0.5, 0)
  76.     MainTitle.Size = UDim2.new(0.834, -14,0, 14)
  77.     MainTitle.Font = Enum.Font.ArialBold
  78.     MainTitle.Text = ui_title
  79.     MainTitle.TextColor3 = Color3.fromRGB(255,255,255)
  80.     MainTitle.TextSize = 14
  81.     MainTitle.TextWrapped = true
  82.     MainTitle.TextXAlignment = Enum.TextXAlignment.Left
  83.     MainTitle.TextScaled = true
  84.    
  85.     Exit.Name = "Exit"
  86.     Exit.Parent = Title
  87.     Exit.AnchorPoint = Vector2.new(0.5, 0.5)
  88.     Exit.BackgroundTransparency = 1
  89.     Exit.Position = UDim2.new(0.95, 0,0.5, 0)
  90.     Exit.Size = UDim2.new(0, 14,0, 14)
  91.     Exit.Image = "rbxassetid://7072725342"
  92.     Exit.AutoButtonColor = false
  93.    
  94.     UICorner_1.Parent = Exit
  95.     UICorner_1.CornerRadius = UDim.new(0, 8)
  96.  
  97.     UIAspectRatioConstraint_1.Parent = Exit
  98.    
  99.     Dropdown_1.Name = "Dropdown"
  100.     Dropdown_1.Parent = Title
  101.     Dropdown_1.AnchorPoint = Vector2.new(0.5, 0.5)
  102.     Dropdown_1.BackgroundTransparency = 1
  103.     Dropdown_1.Position = UDim2.new(0.85, 0,0.5, 0)
  104.     Dropdown_1.Size = UDim2.new(0, 14,0, 14)
  105.     Dropdown_1.Image = "rbxassetid://7072706796"
  106.     Dropdown_1.AutoButtonColor = false
  107.  
  108.     UICorner_2.Parent = Dropdown_1
  109.     UICorner_2.CornerRadius = UDim.new(0, 8)
  110.    
  111.     UIAspectRatioConstraint_2.Parent = Dropdown_1
  112.  
  113.     UIStroke_2.Parent = Title
  114.     UIStroke_2.Color = Color3.fromRGB(40,40,40)
  115.     UIStroke_2.LineJoinMode = Enum.LineJoinMode.Miter
  116.     UIStroke_2.Thickness = 1
  117.    
  118.     Exit.MouseButton1Click:Connect(function()
  119.         UI:Destroy()
  120.     end)
  121.    
  122.     local titleDropdownStatus: boolean = true
  123.    
  124.     Dropdown_1.MouseEnter:Connect(function()
  125.         Dropdown_1.BackgroundTransparency = 0.85
  126.     end)
  127.    
  128.     Dropdown_1.MouseLeave:Connect(function()
  129.         Dropdown_1.BackgroundTransparency = 1
  130.     end)
  131.    
  132.     Exit.MouseEnter:Connect(function()
  133.         Exit.BackgroundTransparency = 0.85
  134.     end)
  135.    
  136.     Exit.MouseLeave:Connect(function()
  137.         Exit.BackgroundTransparency = 1
  138.     end)
  139.    
  140.     Dropdown_1.MouseButton1Click:Connect(function()
  141.         titleDropdownStatus = not titleDropdownStatus
  142.         local tabsInTabs = {}
  143.        
  144.         for _, tab: Frame in pairs(Tabs:GetChildren()) do
  145.             if tab.Name == "Tab" then
  146.                 table.insert(tabsInTabs, tab)
  147.             end
  148.         end
  149.        
  150.         dropdownFunction(Dropdown_1, tabsInTabs, titleDropdownStatus)
  151.     end)
  152.    
  153.     function UILib:CreateTab(tab_title: string)
  154.         local TabLib = {}
  155.        
  156.         local Tab = Instance.new("Frame")
  157.         local UIListLayout_2 = Instance.new("UIListLayout")
  158.         local Title_2 = Instance.new("Frame")
  159.         local MainTab = Instance.new("TextLabel")
  160.         local Dropdown_2 = Instance.new("ImageButton")
  161.         local UIAspectRatioConstraint_3 = Instance.new("UIAspectRatioConstraint")
  162.         local UIPadding_1 = Instance.new("UIPadding")
  163.         local UICorner_3 = Instance.new("UICorner")
  164.        
  165.         Tab.Name = "Tab"
  166.         Tab.Parent = Tabs
  167.         Tab.AnchorPoint = Vector2.new(0.5, 0.5)
  168.         Tab.AutomaticSize = Enum.AutomaticSize.Y
  169.         Tab.BackgroundTransparency = 1
  170.         Tab.BorderSizePixel = 0
  171.         Tab.Size = UDim2.new(1, 0,0, 20)
  172.        
  173.         UIListLayout_2.Parent = Tab
  174.         UIListLayout_2.HorizontalAlignment = Enum.HorizontalAlignment.Center
  175.         UIListLayout_2.SortOrder = Enum.SortOrder.LayoutOrder
  176.  
  177.         UIPadding_1.Parent = Tab
  178.         UIPadding_1.PaddingTop = UDim.new(0,4)
  179.        
  180.         Title_2.Name = "Title"
  181.         Title_2.Parent = Tab
  182.         Title_2.BackgroundColor3 = Color3.fromRGB(25,25,25)
  183.         Title_2.BorderSizePixel = 0
  184.         Title_2.Size = UDim2.new(1, 0,0, 20)
  185.  
  186.         MainTab.Name = "Main"
  187.         MainTab.Parent = Title_2
  188.         MainTab.AnchorPoint = Vector2.new(0.5, 0.5)
  189.         MainTab.BackgroundTransparency = 1
  190.         MainTab.Position = UDim2.new(0.464, 0,0.5, 0)
  191.         MainTab.Size = UDim2.new(0.928, -14,0, 14)
  192.         MainTab.Font = Enum.Font.Arial
  193.         MainTab.Text = tab_title
  194.         MainTab.TextColor3 = Color3.fromRGB(255,255,255)
  195.         MainTab.TextSize = 14
  196.         MainTab.TextWrapped = true
  197.         MainTab.TextXAlignment = Enum.TextXAlignment.Left
  198.         MainTab.TextScaled = true
  199.        
  200.         Dropdown_2.Name = "Dropdown"
  201.         Dropdown_2.Parent = Title_2
  202.         Dropdown_2.AnchorPoint = Vector2.new(0.5, 0.5)
  203.         Dropdown_2.BackgroundTransparency = 1
  204.         Dropdown_2.Position = UDim2.new(0.95, 0,0.5, 0)
  205.         Dropdown_2.Size = UDim2.new(0, 14,0, 14)
  206.         Dropdown_2.Image = "rbxassetid://7072706796"
  207.         Dropdown_2.AutoButtonColor = false
  208.        
  209.         UICorner_3.Parent = Dropdown_2
  210.         UICorner_3.CornerRadius = UDim.new(0, 8)
  211.        
  212.         UIAspectRatioConstraint_3.Parent = Dropdown_2
  213.        
  214.         local tabDropdownStatus: boolean = true
  215.        
  216.         Dropdown_2.MouseEnter:Connect(function()
  217.             Dropdown_2.BackgroundTransparency = 0.85
  218.         end)
  219.        
  220.         Dropdown_2.MouseLeave:Connect(function()
  221.             Dropdown_2.BackgroundTransparency = 1
  222.         end)
  223.        
  224.         Dropdown_2.MouseButton1Click:Connect(function()
  225.             titleDropdownStatus = not titleDropdownStatus
  226.             local containers = {}
  227.  
  228.             for _, container: Frame in pairs(Tab:GetChildren()) do
  229.                 if container.Name == "Container" then
  230.                     table.insert(containers, container)
  231.                 end
  232.             end
  233.  
  234.             dropdownFunction(Dropdown_2, containers, titleDropdownStatus)
  235.         end)
  236.        
  237.         function TabLib:CreateButton(text: string, callback)
  238.             local Container = Instance.new("Frame")
  239.             local Button = Instance.new("Frame")
  240.             local UIStroke_3 = Instance.new("UIStroke")
  241.             local MainButton = Instance.new("TextButton")
  242.             local MousePointer = Instance.new("ImageLabel")
  243.             local UIAspectRatioConstraint_4 = Instance.new("UIAspectRatioConstraint")
  244.             local ButtonText = Instance.new("TextLabel")
  245.            
  246.             Container.Name = "Container"
  247.             Container.Parent = Tab
  248.             Container.BackgroundTransparency = 1
  249.             Container.Size = UDim2.new(1, 0,0, 40)
  250.            
  251.             Button.Name = "Button"
  252.             Button.Parent = Container
  253.             Button.AnchorPoint = Vector2.new(0.5, 0.5)
  254.             Button.BackgroundTransparency = 1
  255.             Button.BorderSizePixel = 0
  256.             Button.Position = UDim2.new(0.5, 0,0.5, 0)
  257.             Button.Size = UDim2.new(0.9, 0,0.6, 0)
  258.            
  259.             MainButton.Name = "Main"
  260.             MainButton.Parent = Button
  261.             MainButton.Active = true
  262.             MainButton.AnchorPoint = Vector2.new(0.5, 0.5)
  263.             MainButton.AutoButtonColor = false
  264.             MainButton.BackgroundColor3 = Color3.fromRGB(25,25,25)
  265.             MainButton.BorderSizePixel = 0
  266.             MainButton.Position = UDim2.new(0.5, 0,0.5, 0)
  267.             MainButton.Size = UDim2.new(1, 0,1, 0)
  268.             MainButton.Font = Enum.Font.Arial
  269.             MainButton.Text = ""
  270.             MainButton.TextColor3 = Color3.fromRGB(255,255,255)
  271.             MainButton.TextSize = 14
  272.             MainButton.ClipsDescendants = true
  273.            
  274.             UIStroke_3.Parent = Button
  275.             UIStroke_3.Color = Color3.fromRGB(40,40,40)
  276.             UIStroke_3.LineJoinMode = Enum.LineJoinMode.Miter
  277.             UIStroke_3.Thickness = 1
  278.  
  279.             MousePointer.Name = "MousePointer"
  280.             MousePointer.Parent = Button
  281.             MousePointer.AnchorPoint = Vector2.new(0.5, 0.5)
  282.             MousePointer.BackgroundColor3 = Color3.fromRGB(163,162,165)
  283.             MousePointer.BackgroundTransparency = 1
  284.             MousePointer.BorderColor3 = Color3.fromRGB(27,42,53)
  285.             MousePointer.Position = UDim2.new(0.925000012, 0,0.5, 0)
  286.             MousePointer.Size = UDim2.new(0, 12,0, 12)
  287.             MousePointer.Image = "rbxassetid://7072719587"
  288.  
  289.             UIAspectRatioConstraint_4.Parent = MousePointer
  290.  
  291.             ButtonText.Name = "Text"
  292.             ButtonText.Parent = Button
  293.             ButtonText.AnchorPoint = Vector2.new(0.5, 0.5)
  294.             ButtonText.BackgroundColor3 = Color3.fromRGB(255,255,255)
  295.             ButtonText.BackgroundTransparency = 1
  296.             ButtonText.BorderColor3 = Color3.fromRGB(27,42,53)
  297.             ButtonText.Position = UDim2.new(0.375, 0,0.5, 0)
  298.             ButtonText.Size = UDim2.new(0.649999976, 0,0, 14)
  299.             ButtonText.Font = Enum.Font.Arial
  300.             ButtonText.Text = text
  301.             ButtonText.TextColor3 = Color3.fromRGB(255,255,255)
  302.             ButtonText.TextSize = 12
  303.             ButtonText.TextWrapped = true
  304.             ButtonText.TextXAlignment = Enum.TextXAlignment.Left
  305.            
  306.             MainButton.MouseButton1Click:Connect(function()
  307.                 callback()
  308.             end)
  309.         end
  310.        
  311.         function TabLib:CreateInput(text: string, callback)
  312.             local Container = Instance.new("Frame")
  313.             local Input = Instance.new("Frame")
  314.             local UIStroke_4 = Instance.new("UIStroke")
  315.             local MainInput = Instance.new("TextBox")
  316.             local Copy = Instance.new("ImageButton")
  317.             local UIAspectRatioConstraint_5 = Instance.new("UIAspectRatioConstraint")
  318.             local UICorner_4 = Instance.new("UICorner")
  319.            
  320.             Container.Name = "Container"
  321.             Container.Parent = Tab
  322.             Container.BackgroundTransparency = 1
  323.             Container.Size = UDim2.new(1, 0,0, 40)
  324.  
  325.             Input.Name = "Input"
  326.             Input.Parent = Container
  327.             Input.AnchorPoint = Vector2.new(0.5, 0.5)
  328.             Input.BackgroundColor3 = Color3.fromRGB(25,25,25)
  329.             Input.BorderSizePixel = 0
  330.             Input.Position = UDim2.new(0.5, 0,0.5, 0)
  331.             Input.Size = UDim2.new(0.899999976, 0,0.600000024, 0)
  332.  
  333.             UIStroke_4.Parent = Input
  334.             UIStroke_4.Color = Color3.fromRGB(40,40,40)
  335.             UIStroke_4.LineJoinMode = Enum.LineJoinMode.Miter
  336.             UIStroke_4.Thickness = 1
  337.  
  338.             MainInput.Name = "Main"
  339.             MainInput.Parent = Input
  340.             MainInput.Active = true
  341.             MainInput.AnchorPoint = Vector2.new(0.5, 0.5)
  342.             MainInput.BackgroundColor3 = Color3.fromRGB(25,25,25)
  343.             MainInput.BackgroundTransparency = 1
  344.             MainInput.BorderColor3 = Color3.fromRGB(20,20,20)
  345.             MainInput.BorderSizePixel = 0
  346.             MainInput.CursorPosition = -1
  347.             MainInput.Position = UDim2.new(0.447839618, 0,0.5, 0)
  348.             MainInput.Size = UDim2.new(0.795678973, 0,1, 0)
  349.             MainInput.Font = Enum.Font.Arial
  350.             MainInput.PlaceholderColor3 = Color3.fromRGB(140,140,140)
  351.             MainInput.PlaceholderText = text
  352.             MainInput.Text = ""
  353.             MainInput.ClearTextOnFocus = false
  354.             MainInput.TextColor3 = Color3.fromRGB(255,255,255)
  355.             MainInput.TextSize = 14
  356.             MainInput.TextWrapped = true
  357.             MainInput.TextXAlignment = Enum.TextXAlignment.Left
  358.             MainInput.ClipsDescendants = true
  359.            
  360.             Copy.Name = "Copy"
  361.             Copy.Parent = Input
  362.             Copy.AnchorPoint = Vector2.new(0.5, 0.5)
  363.             Copy.BackgroundColor3 = Color3.fromRGB(163,162,165)
  364.             Copy.BackgroundTransparency = 1
  365.             Copy.BorderColor3 = Color3.fromRGB(27,42,53)
  366.             Copy.Position = UDim2.new(0.925000012, 0,0.5, 0)
  367.             Copy.Size = UDim2.new(0, 12,0, 12)
  368.             Copy.Image = "rbxassetid://7072707198"
  369.            
  370.             UICorner_4.Parent = Copy
  371.             UICorner_4.CornerRadius = UDim.new(0, 8)
  372.            
  373.             UIAspectRatioConstraint_5.Parent = Copy
  374.            
  375.             MainInput.FocusLost:Connect(function(enterPressed)
  376.                 if enterPressed then
  377.                     callback(MainInput.Text)
  378.                 end
  379.             end)
  380.            
  381.             Copy.MouseEnter:Connect(function()
  382.                 Copy.BackgroundTransparency = 0.85
  383.             end)
  384.  
  385.             Copy.MouseLeave:Connect(function()
  386.                 Copy.BackgroundTransparency = 1
  387.             end)
  388.            
  389.             Copy.MouseButton1Click:Connect(function()
  390.                 pcall(function()
  391.                     setclipboard(MainInput.Text)
  392.                     warn(("copied %s to clipboard"):format(MainInput.Text))
  393.                 end)
  394.             end)
  395.         end
  396.        
  397.         function TabLib:CreateSwitch(text: string, callback)
  398.             local Container = Instance.new("Frame")
  399.             local SwitchText = Instance.new("TextLabel")
  400.             local Switch = Instance.new("Frame")
  401.             local UICorner_5 = Instance.new("UICorner")
  402.             local SwitchBall = Instance.new("Frame")
  403.             local UICorner_6 = Instance.new("UICorner")
  404.             local UIStroke_3 = Instance.new("UIStroke")
  405.             local SwitchButton = Instance.new("TextButton")
  406.            
  407.             Container.Name = "Container"
  408.             Container.Parent = Tab
  409.             Container.BackgroundTransparency = 1
  410.             Container.Size = UDim2.new(1, 0,0, 40)
  411.  
  412.             SwitchText.Name = "Text"
  413.             SwitchText.Parent = Container
  414.             SwitchText.AnchorPoint = Vector2.new(0.5, 0.5)
  415.             SwitchText.BackgroundColor3 = Color3.fromRGB(255,255,255)
  416.             SwitchText.BackgroundTransparency = 1
  417.             SwitchText.BorderColor3 = Color3.fromRGB(27,42,53)
  418.             SwitchText.Position = UDim2.new(0.35, 0,0.5, 0)
  419.             SwitchText.Size = UDim2.new(0.6, 0,0.6, 0)
  420.             SwitchText.Font = Enum.Font.Arial
  421.             SwitchText.Text = text
  422.             SwitchText.TextColor3 = Color3.fromRGB(255,255,255)
  423.             SwitchText.TextSize = 14
  424.             SwitchText.TextXAlignment = Enum.TextXAlignment.Left
  425.             SwitchText.TextWrapped = true
  426.            
  427.             Switch.Name = "Switch"
  428.             Switch.Parent = Container
  429.             Switch.AnchorPoint = Vector2.new(0.5, 0.5)
  430.             Switch.BackgroundColor3 = Color3.fromRGB(25,25,25)
  431.             Switch.Position = UDim2.new(0.821, 0,0.5, 0)
  432.             Switch.Size = UDim2.new(0.281, 0,0.55, 0)
  433.            
  434.             SwitchButton.Name = "SwitchButton"
  435.             SwitchButton.Parent = Switch
  436.             SwitchButton.BackgroundTransparency = 1
  437.             SwitchButton.Text = ""
  438.             SwitchButton.AnchorPoint = Vector2.new(0.5, 0.5)
  439.             SwitchButton.Position = UDim2.new(0.5, 0, 0.5, 0)
  440.             SwitchButton.Size = UDim2.new(1, 0, 1, 0)
  441.             SwitchButton.AutoButtonColor = false
  442.            
  443.             UIStroke_3.Parent = Switch
  444.             UIStroke_3.Color = Color3.fromRGB(40,40,40)
  445.            
  446.             UICorner_5.Parent = Switch
  447.             UICorner_5.CornerRadius = UDim.new(1,0)
  448.  
  449.             SwitchBall.Name = "Ball"
  450.             SwitchBall.Parent = Switch
  451.             SwitchBall.AnchorPoint = Vector2.new(0.5, 0.5)
  452.             SwitchBall.BackgroundColor3 = Color3.fromRGB(255,255,255)
  453.             SwitchBall.BorderColor3 = Color3.fromRGB(27,42,53)
  454.             SwitchBall.Position = UDim2.new(0.25, 0,0.5, 0)
  455.             SwitchBall.Size = UDim2.new(0, 16,0, 16)
  456.  
  457.             UICorner_6.Parent = SwitchBall
  458.             UICorner_6.CornerRadius = UDim.new(1,123)
  459.            
  460.             local toggled: boolean = false
  461.            
  462.             SwitchButton.MouseButton1Click:Connect(function()
  463.                 toggled = not toggled
  464.                
  465.                 local ballTweenProperties = toggled and {Position = UDim2.new(0.75, 0, 0.5, 0)} or {Position = UDim2.new(0.25, 0, 0.5, 0)}
  466.                 local switchTweenProperties = toggled and {BackgroundColor3 = Color3.fromRGB(0, 200, 255)} or {BackgroundColor3 = Color3.fromRGB(25, 25, 25)}
  467.                
  468.                 local tweenProperties = {{Switch, switchTweenProperties}, {SwitchBall, ballTweenProperties}}
  469.                
  470.                 for _, object in pairs(tweenProperties) do
  471.                     local tween: Tween = tweenservice:Create(object[1], TweenInfo.new(.1), object[2])
  472.                    
  473.                     tween:Play()
  474.                 end
  475.                
  476.                 callback(toggled)              
  477.             end)
  478.         end
  479.        
  480.         return TabLib
  481.     end
  482.    
  483.     return UILib
  484. end
  485.  
  486. return Library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement