Advertisement
Vzurxy

Wally UI Lib V2

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