DuyOnline101

library

Jan 2nd, 2023 (edited)
1,629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.05 KB | None | 0 0
  1. local Library = {Toggle = true,FirstTab = nil,TabCount = 0,ColorTable = {}}
  2.  
  3. local RunService = game:GetService("RunService")
  4. local HttpService = game:GetService("HttpService")
  5. local UserInputService = game:GetService("UserInputService")
  6. _G.windowname = HttpService:GenerateGUID(false)
  7.  
  8. local function MakeDraggable(ClickObject, Object)
  9.     local Dragging = nil
  10.     local DragInput = nil
  11.     local DragStart = nil
  12.     local StartPosition = nil
  13.    
  14.     ClickObject.InputBegan:Connect(function(Input)
  15.         if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
  16.             Dragging = true
  17.             DragStart = Input.Position
  18.             StartPosition = Object.Position
  19.            
  20.             Input.Changed:Connect(function()
  21.                 if Input.UserInputState == Enum.UserInputState.End then
  22.                     Dragging = false
  23.                 end
  24.             end)
  25.         end
  26.     end)
  27.    
  28.     ClickObject.InputChanged:Connect(function(Input)
  29.         if Input.UserInputType == Enum.UserInputType.MouseMovement or Input.UserInputType == Enum.UserInputType.Touch then
  30.             DragInput = Input
  31.         end
  32.     end)
  33.    
  34.     UserInputService.InputChanged:Connect(function(Input)
  35.         if Input == DragInput and Dragging then
  36.             local Delta = Input.Position - DragStart
  37.             Object.Position = UDim2.new(StartPosition.X.Scale, StartPosition.X.Offset + Delta.X, StartPosition.Y.Scale, StartPosition.Y.Offset + Delta.Y)
  38.         end
  39.     end)
  40. end
  41.  
  42. function Library:CreateWindow(Config, Parent)
  43.     local WindowInit = {}
  44.     local Folder = game:GetObjects("rbxassetid://7141683860")[1]
  45.     local Screen = Folder.Bracket:Clone()
  46.     local Main = Screen.Main
  47.     local Holder = Main.Holder
  48.     local Topbar = Main.Topbar
  49.     local TContainer = Holder.TContainer
  50.     local TBContainer = Holder.TBContainer.Holder
  51.     --[[
  52.     -- idk probably fix for exploits that dont have this function
  53.     if syn and syn.protect_gui then
  54.         syn.protect_gui(Screen)
  55.     end
  56.     ]]
  57.    
  58.     Screen.Name = _G.windowname
  59.     Screen.Parent = Parent
  60.     Topbar.WindowName.Text = Config.WindowName
  61.  
  62.     MakeDraggable(Topbar,Main)
  63.     local function CloseAll()
  64.         for _,Tab in pairs(TContainer:GetChildren()) do
  65.             if Tab:IsA("ScrollingFrame") then
  66.                 Tab.Visible = false
  67.             end
  68.         end
  69.     end
  70.     local function ResetAll()
  71.         for _,TabButton in pairs(TBContainer:GetChildren()) do
  72.             if TabButton:IsA("TextButton") then
  73.                 TabButton.BackgroundTransparency = 1
  74.             end
  75.         end
  76.         for _,TabButton in pairs(TBContainer:GetChildren()) do
  77.             if TabButton:IsA("TextButton") then
  78.                 TabButton.Size = UDim2.new(0,480 / Library.TabCount,1,0)
  79.             end
  80.         end
  81.         for _,Pallete in pairs(Screen:GetChildren()) do
  82.             if Pallete:IsA("Frame") and Pallete.Name ~= "Main" then
  83.                 Pallete.Visible = false
  84.             end
  85.         end
  86.     end
  87.     local function KeepFirst()
  88.         for _,Tab in pairs(TContainer:GetChildren()) do
  89.             if Tab:IsA("ScrollingFrame") then
  90.                 if Tab.Name == Library.FirstTab .. " Tab" then
  91.                     Tab.Visible = true
  92.                 else
  93.                     Tab.Visible = false
  94.                 end
  95.             end
  96.         end
  97.         for _,TabButton in pairs(TBContainer:GetChildren()) do
  98.             if TabButton:IsA("TextButton") then
  99.                 if TabButton.Name == Library.FirstTab .. " TabButton" then
  100.                     TabButton.BackgroundTransparency = 0
  101.                 else
  102.                     TabButton.BackgroundTransparency = 1
  103.                 end
  104.             end
  105.         end
  106.     end
  107.     local function Toggle(State)
  108.         if State then
  109.             Main.Visible = true
  110.         elseif not State then
  111.             for _,Pallete in pairs(Screen:GetChildren()) do
  112.                 if Pallete:IsA("Frame") and Pallete.Name ~= "Main" then
  113.                     Pallete.Visible = false
  114.                 end
  115.             end
  116.             Screen.ToolTip.Visible = false
  117.             Main.Visible = false
  118.         end
  119.         Library.Toggle = State
  120.     end
  121.     local function ChangeColor(Color)
  122.         Config.Color = Color
  123.         for i, v in pairs(Library.ColorTable) do
  124.             if v.BackgroundColor3 ~= Color3.fromRGB(50, 50, 50) then
  125.                 v.BackgroundColor3 = Color
  126.             end
  127.         end
  128.     end
  129.  
  130.     function WindowInit:Toggle(State)
  131.         Toggle(State)
  132.     end
  133.  
  134.     function WindowInit:ChangeColor(Color)
  135.         ChangeColor(Color)
  136.     end
  137.  
  138.     function WindowInit:SetBackground(ImageId)
  139.         Holder.Image = "rbxassetid://" .. ImageId
  140.     end
  141.  
  142.     function WindowInit:SetBackgroundColor(Color)
  143.         Holder.ImageColor3 = Color
  144.     end
  145.     function WindowInit:SetBackgroundTransparency(Transparency)
  146.         Holder.ImageTransparency = Transparency
  147.     end
  148.  
  149.     function WindowInit:SetTileOffset(Offset)
  150.         Holder.TileSize = UDim2.new(0,Offset,0,Offset)
  151.     end
  152.     function WindowInit:SetTileScale(Scale)
  153.         Holder.TileSize = UDim2.new(Scale,0,Scale,0)
  154.     end
  155.  
  156.     RunService.RenderStepped:Connect(function()
  157.         if Library.Toggle then
  158.             Screen.ToolTip.Position = UDim2.new(0,UserInputService:GetMouseLocation().X + 10,0,UserInputService:GetMouseLocation().Y - 5)
  159.         end
  160.     end)
  161.  
  162.     function WindowInit:CreateTab(Name)
  163.         local TabInit = {}
  164.         local Tab = Folder.Tab:Clone()
  165.         local TabButton = Folder.TabButton:Clone()
  166.  
  167.         Tab.Name = Name .. " Tab"
  168.         Tab.Parent = TContainer
  169.  
  170.         TabButton.Name = Name .. " TabButton"
  171.         TabButton.Parent = TBContainer
  172.         TabButton.Title.Text = Name
  173.         TabButton.BackgroundColor3 = Config.Color
  174.  
  175.         table.insert(Library.ColorTable, TabButton)
  176.         Library.TabCount = Library.TabCount + 1
  177.         if Library.TabCount == 1 then
  178.             Library.FirstTab = Name
  179.         end
  180.  
  181.         CloseAll()
  182.         ResetAll()
  183.         KeepFirst()
  184.  
  185.         local function GetSide(Longest)
  186.             if Longest then
  187.                 if Tab.LeftSide.ListLayout.AbsoluteContentSize.Y > Tab.RightSide.ListLayout.AbsoluteContentSize.Y then
  188.                     return Tab.LeftSide
  189.                 else
  190.                     return Tab.RightSide
  191.                 end
  192.             else
  193.                 if Tab.LeftSide.ListLayout.AbsoluteContentSize.Y > Tab.RightSide.ListLayout.AbsoluteContentSize.Y then
  194.                     return Tab.RightSide
  195.                 else
  196.                     return Tab.LeftSide
  197.                 end
  198.             end
  199.         end
  200.  
  201.         TabButton.MouseButton1Click:Connect(function()
  202.             CloseAll()
  203.             ResetAll()
  204.             Tab.Visible = true
  205.             TabButton.BackgroundTransparency = 0
  206.         end)
  207.  
  208.         Tab.LeftSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  209.             if GetSide(true).Name == Tab.LeftSide.Name then
  210.                 Tab.CanvasSize = UDim2.new(0,0,0,Tab.LeftSide.ListLayout.AbsoluteContentSize.Y + 15)
  211.             else
  212.                 Tab.CanvasSize = UDim2.new(0,0,0,Tab.RightSide.ListLayout.AbsoluteContentSize.Y + 15)
  213.             end
  214.         end)
  215.         Tab.RightSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  216.             if GetSide(true).Name == Tab.LeftSide.Name then
  217.                 Tab.CanvasSize = UDim2.new(0,0,0,Tab.LeftSide.ListLayout.AbsoluteContentSize.Y + 15)
  218.             else
  219.                 Tab.CanvasSize = UDim2.new(0,0,0,Tab.RightSide.ListLayout.AbsoluteContentSize.Y + 15)
  220.             end
  221.         end)
  222.  
  223.         function TabInit:CreateSection(Name)
  224.             local SectionInit = {}
  225.             local Section = Folder.Section:Clone()
  226.             Section.Name = Name .. " Section"
  227.             Section.Parent = GetSide(false)
  228.  
  229.             Section.Title.Text = Name
  230.             Section.Title.Size = UDim2.new(0,Section.Title.TextBounds.X + 10,0,2)
  231.  
  232.             Section.Container.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  233.                 Section.Size = UDim2.new(1,0,0,Section.Container.ListLayout.AbsoluteContentSize.Y + 15)
  234.             end)
  235.            
  236.             function SectionInit:CreateLabel(Name)
  237.                 local LabelInit = {}
  238.                 local Label = Folder.Label:Clone()
  239.                 Label.Name = Name .. " Label"
  240.                 Label.Parent = Section.Container
  241.                 Label.Text = Name
  242.                 Label.Size = UDim2.new(1,-10,0,Label.TextBounds.Y)
  243.                 function LabelInit:UpdateText(Text)
  244.                     Label.Text = Text
  245.                     Label.Size = UDim2.new(1,-10,0,Label.TextBounds.Y)
  246.                 end
  247.                 return LabelInit
  248.             end
  249.             function SectionInit:CreateButton(Name, Callback)
  250.                 local ButtonInit = {}
  251.                 local Button = Folder.Button:Clone()
  252.                 Button.Name = Name .. " Button"
  253.                 Button.Parent = Section.Container
  254.                 Button.Title.Text = Name
  255.                 Button.Size = UDim2.new(1,-10,0,Button.Title.TextBounds.Y + 5)
  256.                
  257.                 function ButtonInit:UpdateText(Text)
  258.                     Button.Title.Text = Text
  259.                 end
  260.                
  261.                 table.insert(Library.ColorTable, Button)
  262.  
  263.                 Button.MouseButton1Down:Connect(function()
  264.                     Button.BackgroundColor3 = Config.Color
  265.                 end)
  266.  
  267.                 Button.MouseButton1Up:Connect(function()
  268.                     Button.BackgroundColor3 = Color3.fromRGB(50,50,50)
  269.                 end)
  270.  
  271.                 Button.MouseLeave:Connect(function()
  272.                     Button.BackgroundColor3 = Color3.fromRGB(50,50,50)
  273.                 end)
  274.  
  275.                 Button.MouseButton1Click:Connect(function()
  276.                     Callback()
  277.                 end)
  278.  
  279.                 function ButtonInit:AddToolTip(Name)
  280.                     if tostring(Name):gsub(" ", "") ~= "" then
  281.                         Button.MouseEnter:Connect(function()
  282.                             Screen.ToolTip.Text = Name
  283.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  284.                             Screen.ToolTip.Visible = true
  285.                         end)
  286.  
  287.                         Button.MouseLeave:Connect(function()
  288.                             Screen.ToolTip.Visible = false
  289.                         end)
  290.                     end
  291.                 end
  292.  
  293.                 return ButtonInit
  294.             end
  295.             function SectionInit:CreateTextBox(Name, PlaceHolder, NumbersOnly, Callback)
  296.                 local TextBoxInit = {}
  297.                 local TextBox = Folder.TextBox:Clone()
  298.                 TextBox.Name = Name .. " TextBox"
  299.                 TextBox.Parent = Section.Container
  300.                 TextBox.Title.Text = Name
  301.                 TextBox.Background.Input.PlaceholderText = PlaceHolder
  302.                 TextBox.Title.Size = UDim2.new(1,0,0,TextBox.Title.TextBounds.Y + 5)
  303.                 TextBox.Size = UDim2.new(1,-10,0,TextBox.Title.TextBounds.Y + 25)
  304.  
  305.                 TextBox.Background.Input.FocusLost:Connect(function()
  306.                     if NumbersOnly and not tonumber(TextBox.Background.Input.Text) then
  307.                         Callback(tonumber(TextBox.Background.Input.Text))
  308.                         --TextBox.Background.Input.Text = ""
  309.                     else
  310.                         Callback(TextBox.Background.Input.Text)
  311.                         --TextBox.Background.Input.Text = ""
  312.                     end
  313.                 end)
  314.                 function TextBoxInit:SetValue(String)
  315.                     Callback(String)
  316.                     TextBox.Background.Input.Text = String
  317.                 end
  318.                 function TextBoxInit:AddToolTip(Name)
  319.                     if tostring(Name):gsub(" ", "") ~= "" then
  320.                         TextBox.MouseEnter:Connect(function()
  321.                             Screen.ToolTip.Text = Name
  322.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  323.                             Screen.ToolTip.Visible = true
  324.                         end)
  325.  
  326.                         TextBox.MouseLeave:Connect(function()
  327.                             Screen.ToolTip.Visible = false
  328.                         end)
  329.                     end
  330.                 end
  331.                 function TextBoxInit:GetObject()
  332.                     return TextBox
  333.                 end
  334.                 return TextBoxInit
  335.             end
  336.             function SectionInit:CreateToggle(Name, Default, Callback)
  337.                 local DefaultLocal = Default or false
  338.                 local ToggleInit = {}
  339.                 local Toggle = Folder.Toggle:Clone()
  340.                 Toggle.Name = Name .. " Toggle"
  341.                 Toggle.Parent = Section.Container
  342.                 Toggle.Title.Text = Name
  343.                 Toggle.Size = UDim2.new(1,-10,0,Toggle.Title.TextBounds.Y + 5)
  344.                
  345.                 table.insert(Library.ColorTable, Toggle.Toggle)
  346.                 local ToggleState = false
  347.  
  348.                 local function SetState(State)
  349.                     if State then
  350.                         Toggle.Toggle.BackgroundColor3 = Config.Color
  351.                     elseif not State then
  352.                         Toggle.Toggle.BackgroundColor3 = Color3.fromRGB(50,50,50)
  353.                     end
  354.                     ToggleState = State
  355.                     Callback(State)
  356.                 end
  357.  
  358.                 Toggle.MouseButton1Click:Connect(function()
  359.                     ToggleState = not ToggleState
  360.                     SetState(ToggleState)
  361.                 end)
  362.  
  363.                 function ToggleInit:AddToolTip(Name)
  364.                     if tostring(Name):gsub(" ", "") ~= "" then
  365.                         Toggle.MouseEnter:Connect(function()
  366.                             Screen.ToolTip.Text = Name
  367.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  368.                             Screen.ToolTip.Visible = true
  369.                         end)
  370.  
  371.                         Toggle.MouseLeave:Connect(function()
  372.                             Screen.ToolTip.Visible = false
  373.                         end)
  374.                     end
  375.                 end
  376.  
  377.                 if Default == nil then
  378.                     function ToggleInit:SetState(State)
  379.                         SetState(State)
  380.                     end
  381.                 else
  382.                     SetState(DefaultLocal)
  383.                 end
  384.  
  385.                 function ToggleInit:GetState(State)
  386.                     return ToggleState
  387.                 end
  388.  
  389.                 function ToggleInit:CreateKeybind(Bind,Callback)
  390.                     local KeybindInit = {}
  391.                     Bind = Bind or "NONE"
  392.  
  393.                     local WaitingForBind = false
  394.                     local Selected = Bind
  395.                     local Blacklist = {"W","A","S","D","Slash","Tab","Backspace","Escape","Space","Delete","Unknown","Backquote"}
  396.  
  397.                     Toggle.Keybind.Visible = true
  398.                     Toggle.Keybind.Text = "[ " .. Bind .. " ]"
  399.  
  400.                     Toggle.Keybind.MouseButton1Click:Connect(function()
  401.                         Toggle.Keybind.Text = "[ ... ]"
  402.                         WaitingForBind = true
  403.                     end)
  404.  
  405.                     Toggle.Keybind:GetPropertyChangedSignal("TextBounds"):Connect(function()
  406.                         Toggle.Keybind.Size = UDim2.new(0,Toggle.Keybind.TextBounds.X,1,0)
  407.                         Toggle.Title.Size = UDim2.new(1,-Toggle.Keybind.Size.X.Offset - 15,1,0)
  408.                     end)
  409.  
  410.                     UserInputService.InputBegan:Connect(function(Input)
  411.                         if WaitingForBind and Input.UserInputType == Enum.UserInputType.Keyboard then
  412.                             local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.", "")
  413.                             if not table.find(Blacklist, Key) then
  414.                                 Toggle.Keybind.Text = "[ " .. Key .. " ]"
  415.                                 Selected = Key
  416.                             else
  417.                                 Toggle.Keybind.Text = "[ NONE ]"
  418.                                 Selected = "NONE"
  419.                             end
  420.                             WaitingForBind = false
  421.                         elseif Input.UserInputType == Enum.UserInputType.Keyboard then
  422.                             local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.", "")
  423.                             if Key == Selected then
  424.                                 ToggleState = not ToggleState
  425.                                 SetState(ToggleState)
  426.                                 if Callback then
  427.                                     Callback(Key)
  428.                                 end
  429.                             end
  430.                         end
  431.                     end)
  432.  
  433.                     function KeybindInit:SetBind(Key)
  434.                         Toggle.Keybind.Text = "[ " .. Key .. " ]"
  435.                         Selected = Key
  436.                     end
  437.  
  438.                     function KeybindInit:GetBind()
  439.                         return Selected
  440.                     end
  441.  
  442.                     return KeybindInit
  443.                 end
  444.  
  445.                 function ToggleInit:GetObject()
  446.                     return Toggle
  447.                 end
  448.  
  449.                 return ToggleInit
  450.             end
  451.             function SectionInit:CreateSlider(Name, Min, Max, Default, Precise, Callback)
  452.                 local DefaultLocal = Default or 50
  453.                 local SliderInit = {}
  454.                 local Slider = Folder.Slider:Clone()
  455.                 Slider.Name = Name .. " Slider"
  456.                 Slider.Parent = Section.Container
  457.                
  458.                 Slider.Title.Text = Name
  459.                 Slider.Slider.Bar.Size = UDim2.new(Min / Max,0,1,0)
  460.                 Slider.Slider.Bar.BackgroundColor3 = Config.Color
  461.                 Slider.Value.PlaceholderText = tostring(Min / Max)
  462.                 Slider.Title.Size = UDim2.new(1,0,0,Slider.Title.TextBounds.Y + 5)
  463.                 Slider.Size = UDim2.new(1,-10,0,Slider.Title.TextBounds.Y + 15)
  464.                 table.insert(Library.ColorTable, Slider.Slider.Bar)
  465.  
  466.                 local GlobalSliderValue = 0
  467.                 local Dragging = false
  468.                 local function Sliding(Input)
  469.                     local Position = UDim2.new(math.clamp((Input.Position.X - Slider.Slider.AbsolutePosition.X) / Slider.Slider.AbsoluteSize.X,0,1),0,1,0)
  470.                     Slider.Slider.Bar.Size = Position
  471.                     local SliderPrecise = ((Position.X.Scale * Max) / Max) * (Max - Min) + Min
  472.                     local SliderNonPrecise = math.floor(((Position.X.Scale * Max) / Max) * (Max - Min) + Min)
  473.                     local SliderValue = Precise and SliderNonPrecise or SliderPrecise
  474.                     SliderValue = tonumber(string.format("%.2f", SliderValue))
  475.                     GlobalSliderValue = SliderValue
  476.                     Slider.Value.PlaceholderText = tostring(SliderValue)
  477.                     Callback(GlobalSliderValue)
  478.                 end
  479.                 local function SetValue(Value)
  480.                     GlobalSliderValue = Value
  481.                     Slider.Slider.Bar.Size = UDim2.new(Value / Max,0,1,0)
  482.                     Slider.Value.PlaceholderText = Value
  483.                     Callback(Value)
  484.                 end
  485.                 Slider.Value.FocusLost:Connect(function()
  486.                     if not tonumber(Slider.Value.Text) then
  487.                         Slider.Value.Text = GlobalSliderValue
  488.                     elseif Slider.Value.Text == "" or tonumber(Slider.Value.Text) <= Min then
  489.                         Slider.Value.Text = Min
  490.                     elseif Slider.Value.Text == "" or tonumber(Slider.Value.Text) >= Max then
  491.                         Slider.Value.Text = Max
  492.                     end
  493.        
  494.                     GlobalSliderValue = Slider.Value.Text
  495.                     Slider.Slider.Bar.Size = UDim2.new(Slider.Value.Text / Max,0,1,0)
  496.                     Slider.Value.PlaceholderText = Slider.Value.Text
  497.                     Callback(tonumber(Slider.Value.Text))
  498.                     Slider.Value.Text = ""
  499.                 end)
  500.  
  501.                 Slider.InputBegan:Connect(function(Input)
  502.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  503.                         Sliding(Input)
  504.                         Dragging = true
  505.                     end
  506.                 end)
  507.  
  508.                 Slider.InputEnded:Connect(function(Input)
  509.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  510.                         Dragging = false
  511.                     end
  512.                 end)
  513.  
  514.                 UserInputService.InputBegan:Connect(function(Input)
  515.                     if Input.KeyCode == Enum.KeyCode.LeftControl then
  516.                         Slider.Value.ZIndex = 4
  517.                     end
  518.                 end)
  519.  
  520.                 UserInputService.InputEnded:Connect(function(Input)
  521.                     if Input.KeyCode == Enum.KeyCode.LeftControl then
  522.                         Slider.Value.ZIndex = 3
  523.                     end
  524.                 end)
  525.  
  526.                 UserInputService.InputChanged:Connect(function(Input)
  527.                     if Dragging and Input.UserInputType == Enum.UserInputType.MouseMovement then
  528.                         Sliding(Input)
  529.                     end
  530.                 end)
  531.  
  532.                 function SliderInit:AddToolTip(Name)
  533.                     if tostring(Name):gsub(" ", "") ~= "" then
  534.                         Slider.MouseEnter:Connect(function()
  535.                             Screen.ToolTip.Text = Name
  536.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  537.                             Screen.ToolTip.Visible = true
  538.                         end)
  539.  
  540.                         Slider.MouseLeave:Connect(function()
  541.                             Screen.ToolTip.Visible = false
  542.                         end)
  543.                     end
  544.                 end
  545.  
  546.                 if Default == nil then
  547.                     function SliderInit:SetValue(Value)
  548.                         GlobalSliderValue = Value
  549.                         Slider.Slider.Bar.Size = UDim2.new(Value / Max,0,1,0)
  550.                         Slider.Value.PlaceholderText = Value
  551.                         Callback(Value)
  552.                     end
  553.                 else
  554.                     SetValue(DefaultLocal)
  555.                 end
  556.  
  557.                 function SliderInit:GetValue(Value)
  558.                     return GlobalSliderValue
  559.                 end
  560.  
  561.                 function SliderInit:GetMin()
  562.                     return Min
  563.                 end
  564.  
  565.                 function SliderInit:GetMax()
  566.                     return Max
  567.                 end
  568.  
  569.                 function SliderInit:GetObject()
  570.                     return Slider
  571.                 end
  572.  
  573.                 return SliderInit
  574.             end
  575.             function SectionInit:CreateDropdown(Name, OptionTable, Callback, InitialValue)
  576.                 local DropdownInit = {}
  577.                 local Dropdown = Folder.Dropdown:Clone()
  578.                 Dropdown.Name = Name .. " Dropdown"
  579.                 Dropdown.Parent = Section.Container
  580.  
  581.                 Dropdown.Title.Text = Name
  582.                 Dropdown.Title.Size = UDim2.new(1,0,0,Dropdown.Title.TextBounds.Y + 5)
  583.                 Dropdown.Container.Position = UDim2.new(0,0,0,Dropdown.Title.TextBounds.Y + 5)
  584.                 Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Title.TextBounds.Y + 25)
  585.  
  586.                 local DropdownToggle = false
  587.  
  588.                 Dropdown.MouseButton1Click:Connect(function()
  589.                     DropdownToggle = not DropdownToggle
  590.                     if DropdownToggle then
  591.                         Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  592.                         Dropdown.Container.Holder.Visible = true
  593.                     else
  594.                         Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Title.TextBounds.Y + 25)
  595.                         Dropdown.Container.Holder.Visible = false
  596.                     end
  597.                 end)
  598.  
  599.                 for _,OptionName in pairs(OptionTable) do
  600.                     local Option = Folder.Option:Clone()
  601.                     Option.Name = OptionName
  602.                     Option.Parent = Dropdown.Container.Holder.Container
  603.  
  604.                     Option.Title.Text = OptionName
  605.                     Option.BackgroundColor3 = Config.Color
  606.                     Option.Size = UDim2.new(1,0,0,Option.Title.TextBounds.Y + 5)
  607.                     Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  608.                     table.insert(Library.ColorTable, Option)
  609.  
  610.                     Option.MouseButton1Down:Connect(function()
  611.                         Option.BackgroundTransparency = 0
  612.                     end)
  613.  
  614.                     Option.MouseButton1Up:Connect(function()
  615.                         Option.BackgroundTransparency = 1
  616.                     end)
  617.  
  618.                     Option.MouseLeave:Connect(function()
  619.                         Option.BackgroundTransparency = 1
  620.                     end)
  621.  
  622.                     Option.MouseButton1Click:Connect(function()
  623.                         Dropdown.Container.Value.Text = OptionName
  624.                         Callback(OptionName)
  625.                     end)
  626.                 end
  627.                 function DropdownInit:AddToolTip(Name)
  628.                     if tostring(Name):gsub(" ", "") ~= "" then
  629.                         Dropdown.MouseEnter:Connect(function()
  630.                             Screen.ToolTip.Text = Name
  631.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  632.                             Screen.ToolTip.Visible = true
  633.                         end)
  634.  
  635.                         Dropdown.MouseLeave:Connect(function()
  636.                             Screen.ToolTip.Visible = false
  637.                         end)
  638.                     end
  639.                 end
  640.  
  641.                 function DropdownInit:GetOption()
  642.                     return Dropdown.Container.Value.Text
  643.                 end
  644.                 function DropdownInit:SetOption(Name)
  645.                     for _,Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  646.                         if Option:IsA("TextButton") and string.find(Option.Name, Name) then
  647.                             Dropdown.Container.Value.Text = Option.Name
  648.                             Callback(Name)
  649.                         end
  650.                     end
  651.                 end
  652.                 function DropdownInit:RemoveOption(Name)
  653.                     for _,Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  654.                         if Option:IsA("TextButton") and string.find(Option.Name, Name) then
  655.                             Option:Destroy()
  656.                         end
  657.                     end
  658.                     Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  659.                             Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  660.                 end
  661.                 function DropdownInit:ClearOptions()
  662.                     for _, Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  663.                         if Option:IsA("TextButton") then
  664.                             Option:Destroy()
  665.                         end
  666.                     end
  667.                     Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  668.                     Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  669.                 end
  670.                 if InitialValue then
  671.                     DropdownInit:SetOption(InitialValue)
  672.                 end
  673.                 function DropdownInit:GetObject()
  674.                     return Dropdown
  675.                 end
  676.                 return DropdownInit
  677.             end
  678.             function SectionInit:CreateColorpicker(Name,Callback)
  679.                 local ColorpickerInit = {}
  680.                 local Colorpicker = Folder.Colorpicker:Clone()
  681.                 local Pallete = Folder.Pallete:Clone()
  682.  
  683.                 Colorpicker.Name = Name .. " Colorpicker"
  684.                 Colorpicker.Parent = Section.Container
  685.                 Colorpicker.Title.Text = Name
  686.                 Colorpicker.Size = UDim2.new(1,-10,0,Colorpicker.Title.TextBounds.Y + 5)
  687.  
  688.                 Pallete.Name = Name .. " Pallete"
  689.                 Pallete.Parent = Screen
  690.  
  691.                 local ColorTable = {
  692.                     Hue = 1,
  693.                     Saturation = 0,
  694.                     Value = 0
  695.                 }
  696.                 local ColorRender = nil
  697.                 local HueRender = nil
  698.                 local ColorpickerRender = nil
  699.                 local function UpdateColor()
  700.                     Colorpicker.Color.BackgroundColor3 = Color3.fromHSV(ColorTable.Hue,ColorTable.Saturation,ColorTable.Value)
  701.                     Pallete.GradientPallete.BackgroundColor3 = Color3.fromHSV(ColorTable.Hue,1,1)
  702.                     Pallete.Input.InputBox.PlaceholderText = "RGB: " .. math.round(Colorpicker.Color.BackgroundColor3.R* 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.G * 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.B * 255)
  703.                     Callback(Colorpicker.Color.BackgroundColor3)
  704.                 end
  705.  
  706.                 Colorpicker.MouseButton1Click:Connect(function()
  707.                     if not Pallete.Visible then
  708.                         ColorpickerRender = RunService.RenderStepped:Connect(function()
  709.                             Pallete.Position = UDim2.new(0,Colorpicker.Color.AbsolutePosition.X - 129,0,Colorpicker.Color.AbsolutePosition.Y + 52)
  710.                         end)
  711.                         Pallete.Visible = true
  712.                     else
  713.                         Pallete.Visible = false
  714.                         ColorpickerRender:Disconnect()
  715.                     end
  716.                 end)
  717.  
  718.                 Pallete.GradientPallete.InputBegan:Connect(function(Input)
  719.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  720.                         if ColorRender then
  721.                             ColorRender:Disconnect()
  722.                         end
  723.                         ColorRender = RunService.RenderStepped:Connect(function()
  724.                             local Mouse = UserInputService:GetMouseLocation()
  725.                             local ColorX = math.clamp(Mouse.X - Pallete.GradientPallete.AbsolutePosition.X, 0, Pallete.GradientPallete.AbsoluteSize.X) / Pallete.GradientPallete.AbsoluteSize.X
  726.                             local ColorY = math.clamp((Mouse.Y - 37) - Pallete.GradientPallete.AbsolutePosition.Y, 0, Pallete.GradientPallete.AbsoluteSize.Y) / Pallete.GradientPallete.AbsoluteSize.Y
  727.                             Pallete.GradientPallete.Dot.Position = UDim2.new(ColorX,0,ColorY,0)
  728.                             ColorTable.Saturation = ColorX
  729.                             ColorTable.Value = 1 - ColorY
  730.                             UpdateColor()
  731.                         end)
  732.                     end
  733.                 end)
  734.  
  735.                 Pallete.GradientPallete.InputEnded:Connect(function(Input)
  736.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  737.                         if ColorRender then
  738.                             ColorRender:Disconnect()
  739.                         end
  740.                     end
  741.                 end)
  742.  
  743.                 Pallete.ColorSlider.InputBegan:Connect(function(Input)
  744.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  745.                         if HueRender then
  746.                             HueRender:Disconnect()
  747.                         end
  748.                         HueRender = RunService.RenderStepped:Connect(function()
  749.                             local Mouse = UserInputService:GetMouseLocation()
  750.                             local HueX = math.clamp(Mouse.X - Pallete.ColorSlider.AbsolutePosition.X, 0, Pallete.ColorSlider.AbsoluteSize.X) / Pallete.ColorSlider.AbsoluteSize.X
  751.                             ColorTable.Hue = 1 - HueX
  752.                             UpdateColor()
  753.                         end)
  754.                     end
  755.                 end)
  756.  
  757.                 Pallete.ColorSlider.InputEnded:Connect(function(Input)
  758.                     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  759.                         if HueRender then
  760.                             HueRender:Disconnect()
  761.                         end
  762.                     end
  763.                 end)
  764.  
  765.                 function ColorpickerInit:UpdateColor(Color)
  766.                     local Hue, Saturation, Value = Color:ToHSV()
  767.                     Colorpicker.Color.BackgroundColor3 = Color3.fromHSV(Hue,Saturation,Value)
  768.                     Pallete.GradientPallete.BackgroundColor3 = Color3.fromHSV(Hue,1,1)
  769.                     Pallete.Input.InputBox.PlaceholderText = "RGB: " .. math.round(Colorpicker.Color.BackgroundColor3.R* 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.G * 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.B * 255)
  770.                     ColorTable = {
  771.                         Hue = Hue,
  772.                         Saturation = Saturation,
  773.                         Value = Value
  774.                     }
  775.                     Callback(Color)
  776.                 end
  777.  
  778.                 Pallete.Input.InputBox.FocusLost:Connect(function(Enter)
  779.                     if Enter then
  780.                         local ColorString = string.split(string.gsub(Pallete.Input.InputBox.Text," ", ""), ",")
  781.                         ColorpickerInit:UpdateColor(Color3.fromRGB(ColorString[1],ColorString[2],ColorString[3]))
  782.                         Pallete.Input.InputBox.Text = ""
  783.                     end
  784.                 end)
  785.  
  786.                 function ColorpickerInit:AddToolTip(Name)
  787.                     if tostring(Name):gsub(" ", "") ~= "" then
  788.                         Colorpicker.MouseEnter:Connect(function()
  789.                             Screen.ToolTip.Text = Name
  790.                             Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  791.                             Screen.ToolTip.Visible = true
  792.                         end)
  793.  
  794.                         Colorpicker.MouseLeave:Connect(function()
  795.                             Screen.ToolTip.Visible = false
  796.                         end)
  797.                     end
  798.                 end
  799.  
  800.                 function ColorpickerInit:GetObject()
  801.                     return Colorpicker
  802.                 end
  803.  
  804.                 return ColorpickerInit
  805.             end
  806.             return SectionInit
  807.         end
  808.         return TabInit
  809.     end
  810.     return WindowInit
  811. end
  812.  
  813. return Library
Add Comment
Please, Sign In to add comment