BrandonDeVirgin

Untitled

Nov 2nd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.57 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. local rainbow = loadstring(game:HttpGet("https://pastebin.com/raw/0p4Cc3Md",true))()
  3. local library = {
  4.     windowcount = 0;
  5. }
  6.  
  7. local dragger = {};
  8. local resizer = {};
  9.  
  10. do
  11.     local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  12.     local inputService = game:GetService('UserInputService');
  13.     local heartbeat = game:GetService("RunService").Heartbeat;
  14.     function dragger.new(frame)
  15.         local s, event = pcall(function()
  16.             return frame.MouseEnter
  17.         end)
  18.  
  19.         if s then
  20.             frame.Active = true;
  21.  
  22.             event:connect(function()
  23.                 local input = frame.InputBegan:connect(function(key)
  24.                     if key.UserInputType == Enum.UserInputType.MouseButton1 then
  25.                         local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  26.                         while heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  27.                             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', 'Quad', 0.1, true);
  28.                         end
  29.                     end
  30.                 end)
  31.  
  32.                 local leave;
  33.                 leave = frame.MouseLeave:connect(function()
  34.                     input:disconnect();
  35.                     leave:disconnect();
  36.                 end)
  37.             end)
  38.         end
  39.     end
  40.    
  41.     function resizer.new(p, s)
  42.         p:GetPropertyChangedSignal('AbsoluteSize'):connect(function()
  43.             s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  44.         end)
  45.     end
  46. end
  47.  
  48.  
  49. local defaults = {
  50.     txtcolor = Color3.fromRGB(255, 255, 255),
  51.     underline = Color3.fromRGB(0, 255, 191),
  52.     barcolor = Color3.fromRGB(40, 40, 40),
  53.     bgcolor = Color3.fromRGB(30, 30, 30),
  54. }
  55.  
  56. function library:Create(class, props)
  57.     local object = Instance.new(class);
  58.  
  59.     for i, prop in next, props do
  60.         if i ~= "Parent" then
  61.             object[i] = prop;
  62.         end
  63.     end
  64.  
  65.     object.Parent = props.Parent;
  66.     return object;
  67. end
  68.  
  69. function library:CreateWindow(options)
  70.     assert(options.text, "no name");
  71.     local window = {
  72.         count = 0;
  73.         toggles = {},
  74.         closed = false;
  75.     }
  76.  
  77.     local options = options or {};
  78.     setmetatable(options, {__index = defaults})
  79.  
  80.     self.windowcount = self.windowcount + 1;
  81.  
  82.     library.gui = library.gui or self:Create("ScreenGui", {Name = "UILibrary", Parent = game:GetService("CoreGui")})
  83.     window.frame = self:Create("Frame", {
  84.         Name = options.text;
  85.         Parent = self.gui,
  86.         Active = true,
  87.         BackgroundTransparency = 0,
  88.         Size = UDim2.new(0, 190, 0, 30),
  89.         Position = UDim2.new(0, (15 + ((200 * self.windowcount) - 200)), 0, 15),
  90.         BackgroundColor3 = options.barcolor,
  91.         BorderSizePixel = 0;
  92.     })
  93.  
  94.     window.background = self:Create('Frame', {
  95.         Name = 'Background';
  96.         Parent = window.frame,
  97.         BorderSizePixel = 0;
  98.         BackgroundColor3 = options.bgcolor,
  99.         Position = UDim2.new(0, 0, 1, 0),
  100.         Size = UDim2.new(1, 0, 0, 25),
  101.         ClipsDescendants = true;
  102.     })
  103.    
  104.     window.container = self:Create('Frame', {
  105.         Name = 'Container';
  106.         Parent = window.frame,
  107.         BorderSizePixel = 0;
  108.         BackgroundColor3 = options.bgcolor,
  109.         Position = UDim2.new(0, 0, 1, 0),
  110.         Size = UDim2.new(1, 0, 0, 25),
  111.         ClipsDescendants = true;
  112.     })
  113.    
  114.     window.organizer = self:Create('UIListLayout', {
  115.         Name = 'Sorter';
  116.         --Padding = UDim.new(0, 0);
  117.         SortOrder = Enum.SortOrder.LayoutOrder;
  118.         Parent = window.container;
  119.     })
  120.    
  121.     window.padder = self:Create('UIPadding', {
  122.         Name = 'Padding';
  123.         PaddingLeft = UDim.new(0, 10);
  124.         PaddingTop = UDim.new(0, 5);
  125.         Parent = window.container;
  126.     })
  127.  
  128.     window.underLine =  self:Create("Frame", {
  129.         Name = 'Underline';
  130.         Size = UDim2.new(1, 0, 0, 1),
  131.         Position = UDim2.new(0, 0, 1, -1),
  132.         BorderSizePixel = 0;
  133.         BackgroundColor3 = options.underline;
  134.         Parent = window.frame
  135.     })
  136.    
  137.     if options.rainbow == true then
  138.         rainbow.Rainbowify(window.underLine)
  139.     end
  140.  
  141.     local togglebutton = self:Create("TextButton", {
  142.         Name = 'Toggle';
  143.         ZIndex = 2,
  144.         BackgroundTransparency = 1;
  145.         Position = UDim2.new(1, -25, 0, 0),
  146.         Size = UDim2.new(0, 25, 1, 0),
  147.         Text = "-",
  148.         TextSize = 17,
  149.         TextColor3 = options.txtcolor,
  150.         Font = Enum.Font.SourceSans;
  151.         Parent = window.frame,
  152.     });
  153.  
  154.     togglebutton.MouseButton1Click:connect(function()
  155.         window.closed = not window.closed
  156.         togglebutton.Text = (window.closed and "+" or "-")
  157.         if window.closed then
  158.             window:Resize(true, UDim2.new(1, 0, 0, 0))
  159.         else
  160.             window:Resize(true)
  161.         end
  162.     end)
  163.  
  164.     self:Create("TextLabel", {
  165.         Size = UDim2.new(1, 0, 1, 0),
  166.         BackgroundTransparency = 1;
  167.         BorderSizePixel = 0;
  168.         TextColor3 = options.txtcolor,
  169.         TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
  170.         TextSize = 17,
  171.         Font = Enum.Font.SourceSansSemibold;
  172.         Text = options.text or "window",
  173.         Name = "Window",
  174.         Parent = window.frame,
  175.     })
  176.  
  177.     do
  178.         dragger.new(window.frame)
  179.         resizer.new(window.background, window.container);
  180.     end
  181.  
  182.     local function getSize()
  183.         local ySize = 0;
  184.         for i, object in next, window.container:GetChildren() do
  185.             if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  186.                 ySize = ySize + object.AbsoluteSize.Y
  187.             end
  188.         end
  189.         return UDim2.new(1, 0, 0, ySize + 10)
  190.     end
  191.  
  192.     function window:Resize(tween, change)
  193.         local size = change or getSize()
  194.         self.container.ClipsDescendants = true;
  195.        
  196.         if tween then
  197.             self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  198.         else
  199.             self.background.Size = size
  200.         end
  201.     end
  202.  
  203.     function window:AddToggle(text, callback)
  204.         self.count = self.count + 1
  205.  
  206.         callback = callback or function() end
  207.         local label = library:Create("TextLabel", {
  208.             Text =  text,
  209.             Size = UDim2.new(1, -10, 0, 20);
  210.             --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  211.             BackgroundTransparency = 1;
  212.             TextColor3 = Color3.fromRGB(255, 255, 255);
  213.             TextXAlignment = Enum.TextXAlignment.Left;
  214.             LayoutOrder = self.Count;
  215.             TextSize = 16,
  216.             Font = Enum.Font.SourceSans,
  217.             Parent = self.container;
  218.         })
  219.  
  220.         local button = library:Create("TextButton", {
  221.             Text = "OFF",
  222.             TextColor3 = Color3.fromRGB(255, 25, 25),
  223.             BackgroundTransparency = 1;
  224.             Position = UDim2.new(1, -25, 0, 0),
  225.             Size = UDim2.new(0, 25, 1, 0),
  226.             TextSize = 17,
  227.             Font = Enum.Font.SourceSansSemibold,
  228.             Parent = label;
  229.         })
  230.  
  231.         button.MouseButton1Click:connect(function()
  232.             self.toggles[text] = (not self.toggles[text])
  233.             button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
  234.             button.Text =(self.toggles[text] and "ON" or "OFF")
  235.  
  236.             callback(self.toggles[text])
  237.         end)
  238.  
  239.         self:Resize()
  240.         return button
  241.     end
  242.  
  243.     function window:AddBox(text, callback)
  244.         self.count = self.count + 1
  245.         callback = callback or function() end
  246.  
  247.         local box = library:Create("TextBox", {
  248.             PlaceholderText = text,
  249.             Size = UDim2.new(1, -10, 0, 20);
  250.             --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  251.             BackgroundTransparency = 0.75;
  252.             BackgroundColor3 = options.boxcolor,
  253.             TextColor3 = Color3.fromRGB(255, 255, 255);
  254.             TextXAlignment = Enum.TextXAlignment.Center;
  255.             TextSize = 16,
  256.             Text = "",
  257.             Font = Enum.Font.SourceSans,
  258.             LayoutOrder = self.Count;
  259.             BorderSizePixel = 0;
  260.             Parent = self.container;
  261.         })
  262.  
  263.         box.FocusLost:connect(function(...)
  264.             callback(box, ...)
  265.         end)
  266.  
  267.         self:Resize()
  268.         return box
  269.     end
  270.  
  271.     function window:AddButton(text, callback)
  272.         self.count = self.count + 1
  273.  
  274.         callback = callback or function() end
  275.         local button = library:Create("TextButton", {
  276.             Text =  text,
  277.             Size = UDim2.new(1, -10, 0, 20);
  278.             --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  279.             BackgroundTransparency = 1;
  280.             TextColor3 = Color3.fromRGB(255, 255, 255);
  281.             TextXAlignment = Enum.TextXAlignment.Left;
  282.             TextSize = 16,
  283.             Font = Enum.Font.SourceSans,
  284.             LayoutOrder = self.Count;
  285.             Parent = self.container;
  286.         })
  287.  
  288.         button.MouseButton1Click:connect(callback)
  289.         self:Resize()
  290.         return button
  291.     end
  292.    
  293.     function window:AddLabel(text)
  294.         self.count = self.count + 1;
  295.        
  296.         local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  297.  
  298.         local button = library:Create("TextLabel", {
  299.             Text =  text,
  300.             Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  301.             TextScaled = false;
  302.             BackgroundTransparency = 1;
  303.             TextColor3 = Color3.fromRGB(255, 255, 255);
  304.             TextXAlignment = Enum.TextXAlignment.Left;
  305.             TextSize = 16,
  306.             Font = Enum.Font.SourceSans,
  307.             LayoutOrder = self.Count;
  308.             Parent = self.container;
  309.         })
  310.  
  311.         self:Resize()
  312.         return button
  313.     end
  314.  
  315.     function window:AddDropdown(options, callback)
  316.         self.count = self.count + 1
  317.         local default = options[1] or "";
  318.        
  319.         callback = callback or function() end
  320.         local dropdown = library:Create("TextLabel", {
  321.             Size = UDim2.new(1, -10, 0, 20);
  322.             BackgroundTransparency = 0.75;
  323.             BackgroundColor3 = options.boxcolor,
  324.             TextColor3 = Color3.fromRGB(255, 255, 255);
  325.             TextXAlignment = Enum.TextXAlignment.Center;
  326.             TextSize = 16,
  327.             Text = default,
  328.             Font = Enum.Font.SourceSans,
  329.             BorderSizePixel = 0;
  330.             LayoutOrder = self.Count;
  331.             Parent = self.container;
  332.         })
  333.        
  334.         local button = library:Create("ImageButton",{
  335.             BackgroundTransparency = 1;
  336.             Image = 'rbxassetid://3234893186';
  337.             Size = UDim2.new(0, 18, 1, 0);
  338.             Position = UDim2.new(1, -20, 0, 0);
  339.             Parent = dropdown;
  340.         })
  341.        
  342.         local frame;
  343.        
  344.         local function isInGui(frame)
  345.             local mloc = game:GetService('UserInputService'):GetMouseLocation();
  346.             local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  347.            
  348.             local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  349.             local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  350.        
  351.             return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  352.         end
  353.  
  354.         local function count(t)
  355.             local c = 0;
  356.             for i, v in next, t do
  357.                 c = c + 1
  358.             end
  359.             return c;
  360.         end
  361.        
  362.         button.MouseButton1Click:connect(function()
  363.             if count(options) == 0 then
  364.                 return
  365.             end
  366.  
  367.             if frame then
  368.                 frame:Destroy();
  369.                 frame = nil;
  370.             end
  371.            
  372.             self.container.ClipsDescendants = false;
  373.  
  374.             frame = library:Create('Frame', {
  375.                 Position = UDim2.new(0, 0, 1, 0);
  376.                 BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  377.                 Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  378.                 BorderSizePixel = 0;
  379.                 Parent = dropdown;
  380.                 ClipsDescendants = true;
  381.                 ZIndex = 2;
  382.             })
  383.            
  384.             library:Create('UIListLayout', {
  385.                 Name = 'Layout';
  386.                 Parent = frame;
  387.             })
  388.  
  389.             for i, option in next, options do
  390.                 local selection = library:Create('TextButton', {
  391.                     Text = option;
  392.                     BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  393.                     TextColor3 = Color3.fromRGB(255, 255, 255);
  394.                     BorderSizePixel = 0;
  395.                     TextSize = 16;
  396.                     Font = Enum.Font.SourceSans;
  397.                     Size = UDim2.new(1, 0, 0, 21);
  398.                     Parent = frame;
  399.                     ZIndex = 2;
  400.                 })
  401.                
  402.                 selection.MouseButton1Click:connect(function()
  403.                     dropdown.Text = option;
  404.                     callback(option)
  405.                     frame.Size = UDim2.new(1, 0, 0, 0);
  406.                     game:GetService('Debris'):AddItem(frame, 0.1)
  407.                 end)
  408.             end
  409.         end);
  410.  
  411.         game:GetService('UserInputService').InputBegan:connect(function(m)
  412.             if m.UserInputType == Enum.UserInputType.MouseButton1 then
  413.                 if frame and (not isInGui(frame)) then
  414.                     game:GetService('Debris'):AddItem(frame);
  415.                 end
  416.             end
  417.         end)
  418.        
  419.         callback(default);
  420.         self:Resize()
  421.         return {
  422.             Refresh = function(self, array)
  423.                 game:GetService('Debris'):AddItem(frame);
  424.                 options = array
  425.                 dropdown.Text = options[1];
  426.             end
  427.         }
  428.     end;
  429.    
  430.    
  431.     return window
  432. end
  433.  
  434. return library
Advertisement
Add Comment
Please, Sign In to add comment