Vzurxy

Wally UI Library V2

Oct 9th, 2019
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 49.29 KB | None | 0 0
  1. --[[
  2.  
  3. class Window [
  4.     Table flags -> default location for values
  5.  
  6.     Method Section(name)
  7.         @name -> text for the Section
  8.  
  9.     Method Toggle(name, options, callback)
  10.         @name -> text for toggle
  11.         @options -> array
  12.             location (table) -> alternate table to put value in (default = window.flags)
  13.             flag (string) -> index for value (e.g location.farming)
  14.         @callback -> function to call when toggle is changed
  15.  
  16.         return -> [
  17.             Method Set(number) -> sets toggle value
  18.         ]
  19.  
  20.     Method Slider(name, options, callback)
  21.         @name -> text for slider
  22.         @options -> array
  23.             location (table) -> alternate table to put value in (default = window.flags)
  24.             flag (string) -> index for value (e.g location.farming)
  25.             precise (boolean) -> wether to show full number or not -- e.g 0, 1 vs 0, 0.1, 0.2, ...
  26.             default (number) -> default slider value
  27.             min, max (number) -> self explanatory
  28.         @callback(value) -> function to call when slider is changed
  29.  
  30.         return -> [
  31.             Method Set(number) -> sets slider value
  32.         ]
  33.  
  34.     Method Dropdown(name, options, callback)
  35.         @name -> text for dropdown
  36.         @options -> array
  37.             location (table) -> alternate table to put value in (default = window.flags)
  38.             flag (string) -> index for value (e.g location.farming)
  39.             list -> list of objects to display
  40.         @callback(new) -> function to call when dropdown is changed
  41.  
  42.         return -> [
  43.             Method Refresh(array) -> resets dropdown.list and sets value to first value in array
  44.         ]
  45.  
  46.     Method Button(name, callback)
  47.         @name -> text for button
  48.         @callback -> function to call when button is clicked
  49.  
  50.         return -> [
  51.             Method Fire(<void>) -> calls callback
  52.         ]
  53.  
  54.     Method Bind(name, options, callback)
  55.         @name -> text for keybind
  56.         @options -> array
  57.             location (table)  -> alternate table to put value in (default = window.flags)
  58.             flag (string)     -> index for value (e.g location.farming)
  59.             kbonly (bool)     -> keyboard keys only (no mouse)
  60.             default (bool)    -> default key for bind;
  61.  
  62.         @callback(key) -> function to call when bind is changed
  63.  
  64.     Method Box(name, options, callback)
  65.         @name -> text for box
  66.         @options -> array
  67.             location (table)  -> alternate table to put value in (default = window.flags)
  68.             flag     (string) -> index for value (e.g location.farming)
  69.             min, max   (number) -> self explanatory
  70.             type (string) -> if type is "number", box will only accept numbers
  71.            
  72.         @callback(box, new, old, enter) -> function to call when box is changed
  73.             box -> box object;
  74.             new -> new value;
  75.             old -> old value;
  76.             enter -> wether enter was pressed
  77.  
  78.         returns -> box object (Instance)
  79.  
  80.     Method SearchBox(name, options, callback)
  81.         @name -> text for searchbox
  82.         @options -> array
  83.             location (table) -> alternate table to put value in (default = window.flags)
  84.             flag (string) -> index for value (e.g location.farming)
  85.             list -> list of objects to search for
  86.         @callback(new) -> function to call when dropdown is changed
  87.  
  88.         return -> [
  89.             Method Refresh(array) -> resets dropdown.list and sets value to first value in array
  90.         ]
  91. ]
  92.  
  93. ]]--
  94.  
  95.  
  96. local library = {count = 0, queue = {}, callbacks = {}, rainbowtable = {}, toggled = true, binds = {}};
  97. local defaults; do
  98.     local dragger = {}; do
  99.         local mouse        = game:GetService("Players").LocalPlayer:GetMouse();
  100.         local inputService = game:GetService('UserInputService');
  101.         local heartbeat    = game:GetService("RunService").Heartbeat;
  102.         -- // credits to Ririchi / Inori for this cute drag function :)
  103.         function dragger.new(frame)
  104.             local s, event = pcall(function()
  105.                 return frame.MouseEnter
  106.             end)
  107.    
  108.             if s then
  109.                 frame.Active = true;
  110.                
  111.                 event:connect(function()
  112.                     local input = frame.InputBegan:connect(function(key)
  113.                         if key.UserInputType == Enum.UserInputType.MouseButton1 then
  114.                             local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  115.                             while heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  116.                                 pcall(function()
  117.                                     frame:TweenPosition(UDim2.new(0, mouse.X - objectPosition.X + (frame.Size.X.Offset * frame.AnchorPoint.X), 0, mouse.Y - objectPosition.Y + (frame.Size.Y.Offset * frame.AnchorPoint.Y)), 'Out', 'Linear', 0.1, true);
  118.                                 end)
  119.                             end
  120.                         end
  121.                     end)
  122.    
  123.                     local leave;
  124.                     leave = frame.MouseLeave:connect(function()
  125.                         input:disconnect();
  126.                         leave:disconnect();
  127.                     end)
  128.                 end)
  129.             end
  130.         end
  131.  
  132.         game:GetService('UserInputService').InputBegan:connect(function(key, gpe)
  133.             if (not gpe) then
  134.                 if key.KeyCode == Enum.KeyCode.RightControl then
  135.                     library.toggled = not library.toggled;
  136.                     for i, data in next, library.queue do
  137.                         local pos = (library.toggled and data.p or UDim2.new(-1, 0, -0.5,0))
  138.                         data.w:TweenPosition(pos, (library.toggled and 'Out' or 'In'), 'Quad', 0.15, true)
  139.                         wait();
  140.                     end
  141.                 end
  142.             end
  143.         end)
  144.     end
  145.    
  146.     local types = {}; do
  147.         types.__index = types;
  148.         function types.window(name, options)
  149.             library.count = library.count + 1
  150.             local newWindow = library:Create('Frame', {
  151.                 Name = name;
  152.                 Size = UDim2.new(0, 190, 0, 30);
  153.                 BackgroundColor3 = options.topcolor;
  154.                 BorderSizePixel = 0;
  155.                 Parent = library.container;
  156.                 Position = UDim2.new(0, (15 + (200 * library.count) - 200), 0, 0);
  157.                 ZIndex = 3;
  158.                 library:Create('TextLabel', {
  159.                     Text = name;
  160.                     Size = UDim2.new(1, -10, 1, 0);
  161.                     Position = UDim2.new(0, 5, 0, 0);
  162.                     BackgroundTransparency = 1;
  163.                     Font = Enum.Font.Code;
  164.                     TextSize = options.titlesize;
  165.                     Font = options.titlefont;
  166.                     TextColor3 = options.titletextcolor;
  167.                     TextStrokeTransparency = library.options.titlestroke;
  168.                     TextStrokeColor3 = library.options.titlestrokecolor;
  169.                     ZIndex = 3;
  170.                 });
  171.                 library:Create("TextButton", {
  172.                     Size = UDim2.new(0, 30, 0, 30);
  173.                     Position = UDim2.new(1, -35, 0, 0);
  174.                     BackgroundTransparency = 1;
  175.                     Text = "-";
  176.                     TextSize = options.titlesize;
  177.                     Font = options.titlefont;--Enum.Font.Code;
  178.                     Name = 'window_toggle';
  179.                     TextColor3 = options.titletextcolor;
  180.                     TextStrokeTransparency = library.options.titlestroke;
  181.                     TextStrokeColor3 = library.options.titlestrokecolor;
  182.                     ZIndex = 3;
  183.                 });
  184.                 library:Create("Frame", {
  185.                     Name = 'Underline';
  186.                     Size = UDim2.new(1, 0, 0, 2);
  187.                     Position = UDim2.new(0, 0, 1, -2);
  188.                     BackgroundColor3 = (options.underlinecolor ~= "rainbow" and options.underlinecolor or Color3.new());
  189.                     BorderSizePixel = 0;
  190.                     ZIndex = 3;
  191.                 });
  192.                 library:Create('Frame', {
  193.                     Name = 'container';
  194.                     Position = UDim2.new(0, 0, 1, 0);
  195.                     Size = UDim2.new(1, 0, 0, 0);
  196.                     BorderSizePixel = 0;
  197.                     BackgroundColor3 = options.bgcolor;
  198.                     ClipsDescendants = false;
  199.                     library:Create('UIListLayout', {
  200.                         Name = 'List';
  201.                         SortOrder = Enum.SortOrder.LayoutOrder;
  202.                     })
  203.                 });
  204.             })
  205.            
  206.             if options.underlinecolor == "rainbow" then
  207.                 table.insert(library.rainbowtable, newWindow:FindFirstChild('Underline'))
  208.             end
  209.  
  210.             local window = setmetatable({
  211.                 count = 0;
  212.                 object = newWindow;
  213.                 container = newWindow.container;
  214.                 toggled = true;
  215.                 flags   = {};
  216.  
  217.             }, types)
  218.  
  219.             table.insert(library.queue, {
  220.                 w = window.object;
  221.                 p = window.object.Position;
  222.             })
  223.  
  224.             newWindow:FindFirstChild("window_toggle").MouseButton1Click:connect(function()
  225.                 window.toggled = not window.toggled;
  226.                 newWindow:FindFirstChild("window_toggle").Text = (window.toggled and "+" or "-")
  227.                 if (not window.toggled) then
  228.                     window.container.ClipsDescendants = true;
  229.                 end
  230.                 wait();
  231.                 local y = 0;
  232.                 for i, v in next, window.container:GetChildren() do
  233.                     if (not v:IsA('UIListLayout')) then
  234.                         y = y + v.AbsoluteSize.Y;
  235.                     end
  236.                 end
  237.  
  238.                 local targetSize = window.toggled and UDim2.new(1, 0, 0, y+5) or UDim2.new(1, 0, 0, 0);
  239.                 local targetDirection = window.toggled and "In" or "Out"
  240.  
  241.                 window.container:TweenSize(targetSize, targetDirection, "Quad", 0.15, true)
  242.                 wait(.15)
  243.                 if window.toggled then
  244.                     window.container.ClipsDescendants = false;
  245.                 end
  246.             end)
  247.  
  248.             return window;
  249.         end
  250.        
  251.         function types:Resize()
  252.             local y = 0;
  253.             for i, v in next, self.container:GetChildren() do
  254.                 if (not v:IsA('UIListLayout')) then
  255.                     y = y + v.AbsoluteSize.Y;
  256.                 end
  257.             end
  258.             self.container.Size = UDim2.new(1, 0, 0, y+5)
  259.         end
  260.        
  261.         function types:GetOrder()
  262.             local c = 0;
  263.             for i, v in next, self.container:GetChildren() do
  264.                 if (not v:IsA('UIListLayout')) then
  265.                     c = c + 1
  266.                 end
  267.             end
  268.             return c
  269.         end
  270.        
  271.         function types:Toggle(name, options, callback)
  272.             local default  = options.default or false;
  273.             local location = options.location or self.flags;
  274.             local flag     = options.flag or "";
  275.             local callback = callback or function() end;
  276.            
  277.             location[flag] = default;
  278.  
  279.             local check = library:Create('Frame', {
  280.                 BackgroundTransparency = 1;
  281.                 Size = UDim2.new(1, 0, 0, 25);
  282.                 LayoutOrder = self:GetOrder();
  283.                 library:Create('TextLabel', {
  284.                     Name = name;
  285.                     Text = "\r" .. name;
  286.                     BackgroundTransparency = 1;
  287.                     TextColor3 = library.options.textcolor;
  288.                     Position = UDim2.new(0, 5, 0, 0);
  289.                     Size     = UDim2.new(1, -5, 1, 0);
  290.                     TextXAlignment = Enum.TextXAlignment.Left;
  291.                     Font = library.options.font;
  292.                     TextSize = library.options.fontsize;
  293.                     TextStrokeTransparency = library.options.textstroke;
  294.                     TextStrokeColor3 = library.options.strokecolor;
  295.                     library:Create('TextButton', {
  296.                         Text = (location[flag] and utf8.char(10003) or "");
  297.                         Font = library.options.font;
  298.                         TextSize = library.options.fontsize;
  299.                         Name = 'Checkmark';
  300.                         Size = UDim2.new(0, 20, 0, 20);
  301.                         Position = UDim2.new(1, -25, 0, 4);
  302.                         TextColor3 = library.options.textcolor;
  303.                         BackgroundColor3 = library.options.bgcolor;
  304.                         BorderColor3 = library.options.bordercolor;
  305.                         TextStrokeTransparency = library.options.textstroke;
  306.                         TextStrokeColor3 = library.options.strokecolor;
  307.                     })
  308.                 });
  309.                 Parent = self.container;
  310.             });
  311.                
  312.             local function click(t)
  313.                 location[flag] = not location[flag];
  314.                 callback(location[flag])
  315.                 check:FindFirstChild(name).Checkmark.Text = location[flag] and utf8.char(10003) or "";
  316.             end
  317.  
  318.             check:FindFirstChild(name).Checkmark.MouseButton1Click:connect(click)
  319.             library.callbacks[flag] = click;
  320.  
  321.             if location[flag] == true then
  322.                 callback(location[flag])
  323.             end
  324.  
  325.             self:Resize();
  326.             return {
  327.                 Set = function(self, b)
  328.                     location[flag] = b;
  329.                     callback(location[flag])
  330.                     check:FindFirstChild(name).Checkmark.Text = location[flag] and utf8.char(10003) or "";
  331.                 end
  332.             }
  333.         end
  334.        
  335.         function types:Button(name, callback)
  336.             callback = callback or function() end;
  337.            
  338.             local check = library:Create('Frame', {
  339.                 BackgroundTransparency = 1;
  340.                 Size = UDim2.new(1, 0, 0, 25);
  341.                 LayoutOrder = self:GetOrder();
  342.                 library:Create('TextButton', {
  343.                     Name = name;
  344.                     Text = name;
  345.                     BackgroundColor3 = library.options.btncolor;
  346.                     BorderColor3 = library.options.bordercolor;
  347.                     TextStrokeTransparency = library.options.textstroke;
  348.                     TextStrokeColor3 = library.options.strokecolor;
  349.                     TextColor3 = library.options.textcolor;
  350.                     Position = UDim2.new(0, 5, 0, 5);
  351.                     Size     = UDim2.new(1, -10, 0, 20);
  352.                     Font = library.options.font;
  353.                     TextSize = library.options.fontsize;
  354.                 });
  355.                 Parent = self.container;
  356.             });
  357.            
  358.             check:FindFirstChild(name).MouseButton1Click:connect(callback)
  359.             self:Resize();
  360.  
  361.             return {
  362.                 Fire = function()
  363.                     callback();
  364.                 end
  365.             }
  366.         end
  367.        
  368.         function types:Box(name, options, callback) --type, default, data, location, flag)
  369.             local type   = options.type or "";
  370.             local default = options.default or "";
  371.             local data = options.data
  372.             local location = options.location or self.flags;
  373.             local flag     = options.flag or "";
  374.             local callback = callback or function() end;
  375.             local min      = options.min or 0;
  376.             local max      = options.max or 9e9;
  377.  
  378.             if type == 'number' and (not tonumber(default)) then
  379.                 location[flag] = default;
  380.             else
  381.                 location[flag] = "";
  382.                 default = "";
  383.             end
  384.  
  385.             local check = library:Create('Frame', {
  386.                 BackgroundTransparency = 1;
  387.                 Size = UDim2.new(1, 0, 0, 25);
  388.                 LayoutOrder = self:GetOrder();
  389.                 library:Create('TextLabel', {
  390.                     Name = name;
  391.                     Text = "\r" .. name;
  392.                     BackgroundTransparency = 1;
  393.                     TextColor3 = library.options.textcolor;
  394.                     TextStrokeTransparency = library.options.textstroke;
  395.                     TextStrokeColor3 = library.options.strokecolor;
  396.                     Position = UDim2.new(0, 5, 0, 0);
  397.                     Size     = UDim2.new(1, -5, 1, 0);
  398.                     TextXAlignment = Enum.TextXAlignment.Left;
  399.                     Font = library.options.font;
  400.                     TextSize = library.options.fontsize;
  401.                     library:Create('TextBox', {
  402.                         TextStrokeTransparency = library.options.textstroke;
  403.                         TextStrokeColor3 = library.options.strokecolor;
  404.                         Text = tostring(default);
  405.                         Font = library.options.font;
  406.                         TextSize = library.options.fontsize;
  407.                         Name = 'Box';
  408.                         Size = UDim2.new(0, 60, 0, 20);
  409.                         Position = UDim2.new(1, -65, 0, 3);
  410.                         TextColor3 = library.options.textcolor;
  411.                         BackgroundColor3 = library.options.boxcolor;
  412.                         BorderColor3 = library.options.bordercolor;
  413.                         PlaceholderColor3 = library.options.placeholdercolor;
  414.                     })
  415.                 });
  416.                 Parent = self.container;
  417.             });
  418.        
  419.             local box = check:FindFirstChild(name):FindFirstChild('Box');
  420.             box.FocusLost:connect(function(e)
  421.                 local old = location[flag];
  422.                 if type == "number" then
  423.                     local num = tonumber(box.Text)
  424.                     if (not num) then
  425.                         box.Text = tonumber(location[flag])
  426.                     else
  427.                         location[flag] = math.clamp(num, min, max)
  428.                         box.Text = tonumber(location[flag])
  429.                     end
  430.                 else
  431.                     location[flag] = tostring(box.Text)
  432.                 end
  433.  
  434.                 callback(location[flag], old, e)
  435.             end)
  436.            
  437.             if type == 'number' then
  438.                 box:GetPropertyChangedSignal('Text'):connect(function()
  439.                     box.Text = string.gsub(box.Text, "[%a+]", "");
  440.                 end)
  441.             end
  442.            
  443.             self:Resize();
  444.             return box
  445.         end
  446.        
  447.         function types:Bind(name, options, callback)
  448.             local location     = options.location or self.flags;
  449.             local keyboardOnly = options.kbonly or false
  450.             local flag         = options.flag or "";
  451.             local callback     = callback or function() end;
  452.             local default      = options.default;
  453.  
  454.             if keyboardOnly and (not tostring(default):find('MouseButton')) then
  455.                 location[flag] = default
  456.             end
  457.            
  458.             local banned = {
  459.                 Return = true;
  460.                 Space = true;
  461.                 Tab = true;
  462.                 Unknown = true;
  463.             }
  464.            
  465.             local shortNames = {
  466.                 RightControl = 'RightCtrl';
  467.                 LeftControl = 'LeftCtrl';
  468.                 LeftShift = 'LShift';
  469.                 RightShift = 'RShift';
  470.                 MouseButton1 = "Mouse1";
  471.                 MouseButton2 = "Mouse2";
  472.             }
  473.            
  474.             local allowed = {
  475.                 MouseButton1 = true;
  476.                 MouseButton2 = true;
  477.             }      
  478.  
  479.             local nm = (default and (shortNames[default.Name] or default.Name) or "None");
  480.             local check = library:Create('Frame', {
  481.                 BackgroundTransparency = 1;
  482.                 Size = UDim2.new(1, 0, 0, 30);
  483.                 LayoutOrder = self:GetOrder();
  484.                 library:Create('TextLabel', {
  485.                     Name = name;
  486.                     Text = "\r" .. name;
  487.                     BackgroundTransparency = 1;
  488.                     TextColor3 = library.options.textcolor;
  489.                     Position = UDim2.new(0, 5, 0, 0);
  490.                     Size     = UDim2.new(1, -5, 1, 0);
  491.                     TextXAlignment = Enum.TextXAlignment.Left;
  492.                     Font = library.options.font;
  493.                     TextSize = library.options.fontsize;
  494.                     TextStrokeTransparency = library.options.textstroke;
  495.                     TextStrokeColor3 = library.options.strokecolor;
  496.                     BorderColor3     = library.options.bordercolor;
  497.                     BorderSizePixel  = 1;
  498.                     library:Create('TextButton', {
  499.                         Name = 'Keybind';
  500.                         Text = nm;
  501.                         TextStrokeTransparency = library.options.textstroke;
  502.                         TextStrokeColor3 = library.options.strokecolor;
  503.                         Font = library.options.font;
  504.                         TextSize = library.options.fontsize;
  505.                         Size = UDim2.new(0, 60, 0, 20);
  506.                         Position = UDim2.new(1, -65, 0, 5);
  507.                         TextColor3 = library.options.textcolor;
  508.                         BackgroundColor3 = library.options.bgcolor;
  509.                         BorderColor3     = library.options.bordercolor;
  510.                         BorderSizePixel  = 1;
  511.                     })
  512.                 });
  513.                 Parent = self.container;
  514.             });
  515.              
  516.             local button = check:FindFirstChild(name).Keybind;
  517.             button.MouseButton1Click:connect(function()
  518.                 library.binding = true
  519.  
  520.                 button.Text = "..."
  521.                 local a, b = game:GetService('UserInputService').InputBegan:wait();
  522.                 local name = tostring(a.KeyCode.Name);
  523.                 local typeName = tostring(a.UserInputType.Name);
  524.  
  525.                 if (a.UserInputType ~= Enum.UserInputType.Keyboard and (allowed[a.UserInputType.Name]) and (not keyboardOnly)) or (a.KeyCode and (not banned[a.KeyCode.Name])) then
  526.                     local name = (a.UserInputType ~= Enum.UserInputType.Keyboard and a.UserInputType.Name or a.KeyCode.Name);
  527.                     location[flag] = (a);
  528.                     button.Text = shortNames[name] or name;
  529.                    
  530.                 else
  531.                     if (location[flag]) then
  532.                         if (not pcall(function()
  533.                             return location[flag].UserInputType
  534.                         end)) then
  535.                             local name = tostring(location[flag])
  536.                             button.Text = shortNames[name] or name
  537.                         else
  538.                             local name = (location[flag].UserInputType ~= Enum.UserInputType.Keyboard and location[flag].UserInputType.Name or location[flag].KeyCode.Name);
  539.                             button.Text = shortNames[name] or name;
  540.                         end
  541.                     end
  542.                 end
  543.  
  544.                 wait(0.1)  
  545.                 library.binding = false;
  546.             end)
  547.            
  548.             if location[flag] then
  549.                 button.Text = shortNames[tostring(location[flag].Name)] or tostring(location[flag].Name)
  550.             end
  551.  
  552.             library.binds[flag] = {
  553.                 location = location;
  554.                 callback = callback;
  555.             };
  556.  
  557.             self:Resize();
  558.         end
  559.    
  560.         function types:Section(name)
  561.             local order = self:GetOrder();
  562.             local determinedSize = UDim2.new(1, 0, 0, 25)
  563.             local determinedPos = UDim2.new(0, 0, 0, 4);
  564.             local secondarySize = UDim2.new(1, 0, 0, 20);
  565.                        
  566.             if order == 0 then
  567.                 determinedSize = UDim2.new(1, 0, 0, 21)
  568.                 determinedPos = UDim2.new(0, 0, 0, -1);
  569.                 secondarySize = nil
  570.             end
  571.            
  572.             local check = library:Create('Frame', {
  573.                 Name = 'Section';
  574.                 BackgroundTransparency = 1;
  575.                 Size = determinedSize;
  576.                 BackgroundColor3 = library.options.sectncolor;
  577.                 BorderSizePixel = 0;
  578.                 LayoutOrder = order;
  579.                 library:Create('TextLabel', {
  580.                     Name = 'section_lbl';
  581.                     Text = name;
  582.                     BackgroundTransparency = 0;
  583.                     BorderSizePixel = 0;
  584.                     BackgroundColor3 = library.options.sectncolor;
  585.                     TextColor3 = library.options.textcolor;
  586.                     Position = determinedPos;
  587.                     Size     = (secondarySize or UDim2.new(1, 0, 1, 0));
  588.                     Font = library.options.font;
  589.                     TextSize = library.options.fontsize;
  590.                     TextStrokeTransparency = library.options.textstroke;
  591.                     TextStrokeColor3 = library.options.strokecolor;
  592.                 });
  593.                 Parent = self.container;
  594.             });
  595.        
  596.             self:Resize();
  597.         end
  598.  
  599.         function types:Slider(name, options, callback)
  600.             local default = options.default or options.min;
  601.             local min     = options.min or 0;
  602.             local max      = options.max or 1;
  603.             local location = options.location or self.flags;
  604.             local precise  = options.precise  or false -- e.g 0, 1 vs 0, 0.1, 0.2, ...
  605.             local flag     = options.flag or "";
  606.             local callback = callback or function() end
  607.  
  608.             location[flag] = default;
  609.  
  610.             local check = library:Create('Frame', {
  611.                 BackgroundTransparency = 1;
  612.                 Size = UDim2.new(1, 0, 0, 25);
  613.                 LayoutOrder = self:GetOrder();
  614.                 library:Create('TextLabel', {
  615.                     Name = name;
  616.                     TextStrokeTransparency = library.options.textstroke;
  617.                     TextStrokeColor3 = library.options.strokecolor;
  618.                     Text = "\r" .. name;
  619.                     BackgroundTransparency = 1;
  620.                     TextColor3 = library.options.textcolor;
  621.                     Position = UDim2.new(0, 5, 0, 2);
  622.                     Size     = UDim2.new(1, -5, 1, 0);
  623.                     TextXAlignment = Enum.TextXAlignment.Left;
  624.                     Font = library.options.font;
  625.                     TextSize = library.options.fontsize;
  626.                     library:Create('Frame', {
  627.                         Name = 'Container';
  628.                         Size = UDim2.new(0, 60, 0, 20);
  629.                         Position = UDim2.new(1, -65, 0, 3);
  630.                         BackgroundTransparency = 1;
  631.                         --BorderColor3 = library.options.bordercolor;
  632.                         BorderSizePixel = 0;
  633.                         library:Create('TextLabel', {
  634.                             Name = 'ValueLabel';
  635.                             Text = default;
  636.                             BackgroundTransparency = 1;
  637.                             TextColor3 = library.options.textcolor;
  638.                             Position = UDim2.new(0, -10, 0, 0);
  639.                             Size     = UDim2.new(0, 1, 1, 0);
  640.                             TextXAlignment = Enum.TextXAlignment.Right;
  641.                             Font = library.options.font;
  642.                             TextSize = library.options.fontsize;
  643.                             TextStrokeTransparency = library.options.textstroke;
  644.                             TextStrokeColor3 = library.options.strokecolor;
  645.                         });
  646.                         library:Create('TextButton', {
  647.                             Name = 'Button';
  648.                             Size = UDim2.new(0, 5, 1, -2);
  649.                             Position = UDim2.new(0, 0, 0, 1);
  650.                             AutoButtonColor = false;
  651.                             Text = "";
  652.                             BackgroundColor3 = Color3.fromRGB(20, 20, 20);
  653.                             BorderSizePixel = 0;
  654.                             ZIndex = 2;
  655.                             TextStrokeTransparency = library.options.textstroke;
  656.                             TextStrokeColor3 = library.options.strokecolor;
  657.                         });
  658.                         library:Create('Frame', {
  659.                             Name = 'Line';
  660.                             BackgroundTransparency = 0;
  661.                             Position = UDim2.new(0, 0, 0.5, 0);
  662.                             Size     = UDim2.new(1, 0, 0, 1);
  663.                             BackgroundColor3 = Color3.fromRGB(255, 255, 255);
  664.                             BorderSizePixel = 0;
  665.                         });
  666.                     })
  667.                 });
  668.                 Parent = self.container;
  669.             });
  670.  
  671.             local overlay = check:FindFirstChild(name);
  672.  
  673.             local renderSteppedConnection;
  674.             local inputBeganConnection;
  675.             local inputEndedConnection;
  676.             local mouseLeaveConnection;
  677.             local mouseDownConnection;
  678.             local mouseUpConnection;
  679.  
  680.             check:FindFirstChild(name).Container.MouseEnter:connect(function()
  681.                 local function update()
  682.                     if renderSteppedConnection then renderSteppedConnection:disconnect() end
  683.                    
  684.  
  685.                     renderSteppedConnection = game:GetService('RunService').RenderStepped:connect(function()
  686.                         local mouse = game:GetService("UserInputService"):GetMouseLocation()
  687.                         local percent = (mouse.X - overlay.Container.AbsolutePosition.X) / (overlay.Container.AbsoluteSize.X)
  688.                         percent = math.clamp(percent, 0, 1)
  689.                         percent = tonumber(string.format("%.2f", percent))
  690.  
  691.                         overlay.Container.Button.Position = UDim2.new(math.clamp(percent, 0, 0.99), 0, 0, 1)
  692.                        
  693.                         local num = min + (max - min) * percent
  694.                         local value = (precise and num or math.floor(num))
  695.  
  696.                         overlay.Container.ValueLabel.Text = value;
  697.                         callback(tonumber(value))
  698.                         location[flag] = tonumber(value)
  699.                     end)
  700.                 end
  701.  
  702.                 local function disconnect()
  703.                     if renderSteppedConnection then renderSteppedConnection:disconnect() end
  704.                     if inputBeganConnection then inputBeganConnection:disconnect() end
  705.                     if inputEndedConnection then inputEndedConnection:disconnect() end
  706.                     if mouseLeaveConnection then mouseLeaveConnection:disconnect() end
  707.                     if mouseUpConnection then mouseUpConnection:disconnect() end
  708.                 end
  709.  
  710.                 inputBeganConnection = check:FindFirstChild(name).Container.InputBegan:connect(function(input)
  711.                     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  712.                         update()
  713.                     end
  714.                 end)
  715.  
  716.                 inputEndedConnection = check:FindFirstChild(name).Container.InputEnded:connect(function(input)
  717.                     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  718.                         disconnect()
  719.                     end
  720.                 end)
  721.  
  722.                 mouseDownConnection = check:FindFirstChild(name).Container.Button.MouseButton1Down:connect(update)
  723.                 mouseUpConnection   = game:GetService("UserInputService").InputEnded:connect(function(a, b)
  724.                     if a.UserInputType == Enum.UserInputType.MouseButton1 and (mouseDownConnection.Connected) then
  725.                         disconnect()
  726.                     end
  727.                 end)
  728.             end)    
  729.  
  730.             if default ~= min then
  731.                 local percent = 1 - ((max - default) / (max - min))
  732.                 local number  = default
  733.  
  734.                 number = tonumber(string.format("%.2f", number))
  735.                 if (not precise) then
  736.                     number = math.floor(number)
  737.                 end
  738.  
  739.                 overlay.Container.Button.Position  = UDim2.new(math.clamp(percent, 0, 0.99), 0,  0, 1)
  740.                 overlay.Container.ValueLabel.Text  = number
  741.             end
  742.  
  743.             self:Resize();
  744.             return {
  745.                 Set = function(self, value)
  746.                     local percent = 1 - ((max - value) / (max - min))
  747.                     local number  = value
  748.  
  749.                     number = tonumber(string.format("%.2f", number))
  750.                     if (not precise) then
  751.                         number = math.floor(number)
  752.                     end
  753.  
  754.                     overlay.Container.Button.Position  = UDim2.new(math.clamp(percent, 0, 0.99), 0,  0, 1)
  755.                     overlay.Container.ValueLabel.Text  = number
  756.                     location[flag] = number
  757.                     callback(number)
  758.                 end
  759.             }
  760.         end
  761.  
  762.         function types:SearchBox(text, options, callback)
  763.             local list = options.list or {};
  764.             local flag = options.flag or "";
  765.             local location = options.location or self.flags;
  766.             local callback = callback or function() end;
  767.  
  768.             local busy = false;
  769.             local box = library:Create('Frame', {
  770.                 BackgroundTransparency = 1;
  771.                 Size = UDim2.new(1, 0, 0, 25);
  772.                 LayoutOrder = self:GetOrder();
  773.                 library:Create('TextBox', {
  774.                     Text = "";
  775.                     PlaceholderText = text;
  776.                     PlaceholderColor3 = Color3.fromRGB(60, 60, 60);
  777.                     Font = library.options.font;
  778.                     TextSize = library.options.fontsize;
  779.                     Name = 'Box';
  780.                     Size = UDim2.new(1, -10, 0, 20);
  781.                     Position = UDim2.new(0, 5, 0, 4);
  782.                     TextColor3 = library.options.textcolor;
  783.                     BackgroundColor3 = library.options.dropcolor;
  784.                     BorderColor3 = library.options.bordercolor;
  785.                     TextStrokeTransparency = library.options.textstroke;
  786.                     TextStrokeColor3 = library.options.strokecolor;
  787.                     library:Create('ScrollingFrame', {
  788.                         Position = UDim2.new(0, 0, 1, 1);
  789.                         Name = 'Container';
  790.                         BackgroundColor3 = library.options.btncolor;
  791.                         ScrollBarThickness = 0;
  792.                         BorderSizePixel = 0;
  793.                         BorderColor3 = library.options.bordercolor;
  794.                         Size = UDim2.new(1, 0, 0, 0);
  795.                         library:Create('UIListLayout', {
  796.                             Name = 'ListLayout';
  797.                             SortOrder = Enum.SortOrder.LayoutOrder;
  798.                         });
  799.                         ZIndex = 2;
  800.                     });
  801.                 });
  802.                 Parent = self.container;
  803.             })
  804.  
  805.             local function rebuild(text)
  806.                 box:FindFirstChild('Box').Container.ScrollBarThickness = 0
  807.                 for i, child in next, box:FindFirstChild('Box').Container:GetChildren() do
  808.                     if (not child:IsA('UIListLayout')) then
  809.                         child:Destroy();
  810.                     end
  811.                 end
  812.  
  813.                 if #text > 0 then
  814.                     for i, v in next, list do
  815.                         if string.sub(string.lower(v), 1, string.len(text)) == string.lower(text) then
  816.                             local button = library:Create('TextButton', {
  817.                                 Text = v;
  818.                                 Font = library.options.font;
  819.                                 TextSize = library.options.fontsize;
  820.                                 TextColor3 = library.options.textcolor;
  821.                                 BorderColor3 = library.options.bordercolor;
  822.                                 TextStrokeTransparency = library.options.textstroke;
  823.                                 TextStrokeColor3 = library.options.strokecolor;
  824.                                 Parent = box:FindFirstChild('Box').Container;
  825.                                 Size = UDim2.new(1, 0, 0, 20);
  826.                                 LayoutOrder = i;
  827.                                 BackgroundColor3 = library.options.btncolor;
  828.                                 ZIndex = 2;
  829.                             })
  830.  
  831.                             button.MouseButton1Click:connect(function()
  832.                                 busy = true;
  833.                                 box:FindFirstChild('Box').Text = button.Text;
  834.                                 wait();
  835.                                 busy = false;
  836.  
  837.                                 location[flag] = button.Text;
  838.                                 callback(location[flag])
  839.  
  840.                                 box:FindFirstChild('Box').Container.ScrollBarThickness = 0
  841.                                 for i, child in next, box:FindFirstChild('Box').Container:GetChildren() do
  842.                                     if (not child:IsA('UIListLayout')) then
  843.                                         child:Destroy();
  844.                                     end
  845.                                 end
  846.                                 box:FindFirstChild('Box').Container:TweenSize(UDim2.new(1, 0, 0, 0), 'Out', 'Quad', 0.25, true)
  847.                             end)
  848.                         end
  849.                     end
  850.                 end
  851.  
  852.                 local c = box:FindFirstChild('Box').Container:GetChildren()
  853.                 local ry = (20 * (#c)) - 20
  854.  
  855.                 local y = math.clamp((20 * (#c)) - 20, 0, 100)
  856.                 if ry > 100 then
  857.                     box:FindFirstChild('Box').Container.ScrollBarThickness = 5;
  858.                 end
  859.  
  860.                 box:FindFirstChild('Box').Container:TweenSize(UDim2.new(1, 0, 0, y), 'Out', 'Quad', 0.25, true)
  861.                 box:FindFirstChild('Box').Container.CanvasSize = UDim2.new(1, 0, 0, (20 * (#c)) - 20)
  862.             end
  863.  
  864.             box:FindFirstChild('Box'):GetPropertyChangedSignal('Text'):connect(function()
  865.                 if (not busy) then
  866.                     rebuild(box:FindFirstChild('Box').Text)
  867.                 end
  868.             end);
  869.  
  870.             local function reload(new_list)
  871.                 list = new_list;
  872.                 rebuild("")
  873.             end
  874.             self:Resize();
  875.             return reload, box:FindFirstChild('Box');
  876.         end
  877.        
  878.         function types:Dropdown(name, options, callback)
  879.             local location = options.location or self.flags;
  880.             local flag = options.flag or "";
  881.             local callback = callback or function() end;
  882.             local list = options.list or {};
  883.  
  884.             location[flag] = list[1]
  885.             local check = library:Create('Frame', {
  886.                 BackgroundTransparency = 1;
  887.                 Size = UDim2.new(1, 0, 0, 25);
  888.                 BackgroundColor3 = Color3.fromRGB(25, 25, 25);
  889.                 BorderSizePixel = 0;
  890.                 LayoutOrder = self:GetOrder();
  891.                 library:Create('Frame', {
  892.                     Name = 'dropdown_lbl';
  893.                     BackgroundTransparency = 0;
  894.                     BackgroundColor3 = library.options.dropcolor;
  895.                     Position = UDim2.new(0, 5, 0, 4);
  896.                     BorderColor3 = library.options.bordercolor;
  897.                     Size     = UDim2.new(1, -10, 0, 20);
  898.                     library:Create('TextLabel', {
  899.                         Name = 'Selection';
  900.                         Size = UDim2.new(1, 0, 1, 0);
  901.                         Text = list[1];
  902.                         TextColor3 = library.options.textcolor;
  903.                         BackgroundTransparency = 1;
  904.                         Font = library.options.font;
  905.                         TextSize = library.options.fontsize;
  906.                         TextStrokeTransparency = library.options.textstroke;
  907.                         TextStrokeColor3 = library.options.strokecolor;
  908.                     });
  909.                     library:Create("TextButton", {
  910.                         Name = 'drop';
  911.                         BackgroundTransparency = 1;
  912.                         Size = UDim2.new(0, 20, 1, 0);
  913.                         Position = UDim2.new(1, -25, 0, 0);
  914.                         Text = 'v';
  915.                         TextColor3 = library.options.textcolor;
  916.                         Font = library.options.font;
  917.                         TextSize = library.options.fontsize;
  918.                         TextStrokeTransparency = library.options.textstroke;
  919.                         TextStrokeColor3 = library.options.strokecolor;
  920.                     })
  921.                 });
  922.                 Parent = self.container;
  923.             });
  924.            
  925.             local button = check:FindFirstChild('dropdown_lbl').drop;
  926.             local input;
  927.            
  928.             button.MouseButton1Click:connect(function()
  929.                 if (input and input.Connected) then
  930.                     return
  931.                 end
  932.                
  933.                 check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = Color3.fromRGB(60, 60, 60);
  934.                 check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text = name;
  935.                 local c = 0;
  936.                 for i, v in next, list do
  937.                     c = c + 20;
  938.                 end
  939.  
  940.                 local size = UDim2.new(1, 0, 0, c)
  941.  
  942.                 local clampedSize;
  943.                 local scrollSize = 0;
  944.                 if size.Y.Offset > 100 then
  945.                     clampedSize = UDim2.new(1, 0, 0, 100)
  946.                     scrollSize = 5;
  947.                 end
  948.                
  949.                 local goSize = (clampedSize ~= nil and clampedSize) or size;    
  950.                 local container = library:Create('ScrollingFrame', {
  951.                     TopImage = 'rbxasset://textures/ui/Scroll/scroll-middle.png';
  952.                     BottomImage = 'rbxasset://textures/ui/Scroll/scroll-middle.png';
  953.                     Name = 'DropContainer';
  954.                     Parent = check:FindFirstChild('dropdown_lbl');
  955.                     Size = UDim2.new(1, 0, 0, 0);
  956.                     BackgroundColor3 = library.options.bgcolor;
  957.                     BorderColor3 = library.options.bordercolor;
  958.                     Position = UDim2.new(0, 0, 1, 0);
  959.                     ScrollBarThickness = scrollSize;
  960.                     CanvasSize = UDim2.new(0, 0, 0, size.Y.Offset);
  961.                     ZIndex = 5;
  962.                     ClipsDescendants = true;
  963.                     library:Create('UIListLayout', {
  964.                         Name = 'List';
  965.                         SortOrder = Enum.SortOrder.LayoutOrder
  966.                     })
  967.                 })
  968.  
  969.                 for i, v in next, list do
  970.                     local btn = library:Create('TextButton', {
  971.                         Size = UDim2.new(1, 0, 0, 20);
  972.                         BackgroundColor3 = library.options.btncolor;
  973.                         BorderColor3 = library.options.bordercolor;
  974.                         Text = v;
  975.                         Font = library.options.font;
  976.                         TextSize = library.options.fontsize;
  977.                         LayoutOrder = i;
  978.                         Parent = container;
  979.                         ZIndex = 5;
  980.                         TextColor3 = library.options.textcolor;
  981.                         TextStrokeTransparency = library.options.textstroke;
  982.                         TextStrokeColor3 = library.options.strokecolor;
  983.                     })
  984.                    
  985.                     btn.MouseButton1Click:connect(function()
  986.                         check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  987.                         check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text = btn.Text;
  988.  
  989.                         location[flag] = tostring(btn.Text);
  990.                         callback(location[flag])
  991.  
  992.                         game:GetService('Debris'):AddItem(container, 0)
  993.                         input:disconnect();
  994.                     end)
  995.                 end
  996.                
  997.                 container:TweenSize(goSize, 'Out', 'Quad', 0.15, true)
  998.                
  999.                 local function isInGui(frame)
  1000.                     local mloc = game:GetService('UserInputService'):GetMouseLocation();
  1001.                     local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  1002.                    
  1003.                     local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  1004.                     local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  1005.                
  1006.                     return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  1007.                 end
  1008.                
  1009.                 input = game:GetService('UserInputService').InputBegan:connect(function(a)
  1010.                     if a.UserInputType == Enum.UserInputType.MouseButton1 and (not isInGui(container)) then
  1011.                         check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  1012.                         check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text       = location[flag];
  1013.  
  1014.                         container:TweenSize(UDim2.new(1, 0, 0, 0), 'In', 'Quad', 0.15, true)
  1015.                         wait(0.15)
  1016.  
  1017.                         game:GetService('Debris'):AddItem(container, 0)
  1018.                         input:disconnect();
  1019.                     end
  1020.                 end)
  1021.             end)
  1022.            
  1023.             self:Resize();
  1024.             local function reload(self, array)
  1025.                 options = array;
  1026.                 location[flag] = array[1];
  1027.                 pcall(function()
  1028.                     input:disconnect()
  1029.                 end)
  1030.                 check:WaitForChild('dropdown_lbl').Selection.Text = location[flag]
  1031.                 check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  1032.                 game:GetService('Debris'):AddItem(container, 0)
  1033.             end
  1034.  
  1035.             return {
  1036.                 Refresh = reload;
  1037.             }
  1038.         end
  1039.     end
  1040.    
  1041.     function library:Create(class, data)
  1042.         local obj = Instance.new(class);
  1043.         for i, v in next, data do
  1044.             if i ~= 'Parent' then
  1045.                
  1046.                 if typeof(v) == "Instance" then
  1047.                     v.Parent = obj;
  1048.                 else
  1049.                     obj[i] = v
  1050.                 end
  1051.             end
  1052.         end
  1053.        
  1054.         obj.Parent = data.Parent;
  1055.         return obj
  1056.     end
  1057.    
  1058.     function library:CreateWindow(name, options)
  1059.         if (not library.container) then
  1060.             library.container = self:Create("ScreenGui", {
  1061.                 self:Create('Frame', {
  1062.                     Name = 'Container';
  1063.                     Size = UDim2.new(1, -30, 1, 0);
  1064.                     Position = UDim2.new(0, 20, 0, 20);
  1065.                     BackgroundTransparency = 1;
  1066.                     Active = false;
  1067.                 });
  1068.                 Parent = game:GetService("CoreGui");
  1069.             }):FindFirstChild('Container');
  1070.         end
  1071.        
  1072.         if (not library.options) then
  1073.             library.options = setmetatable(options or {}, {__index = defaults})
  1074.         end
  1075.        
  1076.         local window = types.window(name, library.options);
  1077.         dragger.new(window.object);
  1078.         return window
  1079.     end
  1080.    
  1081.     default = {
  1082.         topcolor       = Color3.fromRGB(30, 30, 30);
  1083.         titlecolor     = Color3.fromRGB(255, 255, 255);
  1084.        
  1085.         underlinecolor = Color3.fromRGB(0, 255, 140);
  1086.         bgcolor        = Color3.fromRGB(35, 35, 35);
  1087.         boxcolor       = Color3.fromRGB(35, 35, 35);
  1088.         btncolor       = Color3.fromRGB(25, 25, 25);
  1089.         dropcolor      = Color3.fromRGB(25, 25, 25);
  1090.         sectncolor     = Color3.fromRGB(25, 25, 25);
  1091.         bordercolor    = Color3.fromRGB(60, 60, 60);
  1092.  
  1093.         font           = Enum.Font.SourceSans;
  1094.         titlefont      = Enum.Font.Code;
  1095.  
  1096.         fontsize       = 17;
  1097.         titlesize      = 18;
  1098.  
  1099.         textstroke     = 1;
  1100.         titlestroke    = 1;
  1101.  
  1102.         strokecolor    = Color3.fromRGB(0, 0, 0);
  1103.  
  1104.         textcolor      = Color3.fromRGB(255, 255, 255);
  1105.         titletextcolor = Color3.fromRGB(255, 255, 255);
  1106.  
  1107.         placeholdercolor = Color3.fromRGB(255, 255, 255);
  1108.         titlestrokecolor = Color3.fromRGB(0, 0, 0);
  1109.     }
  1110.  
  1111.     library.options = setmetatable({}, {__index = default})
  1112.  
  1113.     spawn(function()
  1114.         while true do
  1115.             for i=0, 1, 1 / 300 do              
  1116.                 for _, obj in next, library.rainbowtable do
  1117.                     obj.BackgroundColor3 = Color3.fromHSV(i, 1, 1);
  1118.                 end
  1119.                 wait()
  1120.             end;
  1121.         end
  1122.     end)
  1123.  
  1124.     local function isreallypressed(bind, inp)
  1125.         local key = bind
  1126.         if typeof(key) == "Instance" then
  1127.             if key.UserInputType == Enum.UserInputType.Keyboard and inp.KeyCode == key.KeyCode then
  1128.                 return true;
  1129.             elseif tostring(key.UserInputType):find('MouseButton') and inp.UserInputType == key.UserInputType then
  1130.                 return true
  1131.             end
  1132.         end
  1133.         if tostring(key):find'MouseButton1' then
  1134.             return key == inp.UserInputType
  1135.         else
  1136.             return key == inp.KeyCode
  1137.         end
  1138.     end
  1139.  
  1140.     game:GetService("UserInputService").InputBegan:connect(function(input)
  1141.         if (not library.binding) then
  1142.             for idx, binds in next, library.binds do
  1143.                 local real_binding = binds.location[idx];
  1144.                 if real_binding and isreallypressed(real_binding, input) then
  1145.                     binds.callback()
  1146.                 end
  1147.             end
  1148.         end
  1149.     end)
  1150. end
  1151.  
  1152. return library
Add Comment
Please, Sign In to add comment