lolgame854

Synp Lib

Feb 28th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.64 KB | None | 0 0
  1. -- Wally library modified by Aztup
  2. -- Design idea by 7th
  3. -- You don't have the perm to use it without the perm of Aztup
  4.  
  5. local Heartbeat = game:GetService("RunService").Heartbeat;
  6. local library = {
  7.     windowcount = 0;
  8. }
  9.  
  10. local defaults = defaults or {
  11.     boxcolor = nil,
  12.     Rainbow = true,
  13.     slidingbarcolor = nil,
  14.     txtcolor = Color3.fromRGB(255, 255, 255),
  15.     underline = Color3.fromRGB(0, 255, 140),
  16.     barcolor = Color3.fromRGB(50, 50, 50),
  17.     bgcolor = Color3.fromRGB(50, 50, 50)
  18. };
  19.  
  20. if game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Aztup's UI") then
  21.     game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("Aztup's UI"):Destroy();
  22. end
  23.  
  24. local tweenPosition = function (object, newpos)
  25.     object.Position = newpos
  26. end;
  27.  
  28. local dragger = {};
  29. local resizer = {};
  30. local frames = {};
  31. local Callbacks = {};
  32. local Enabled = {};
  33.  
  34. do
  35.     local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  36.     local inputService = game:GetService('UserInputService');
  37.    
  38.     function dragger.new(frame)
  39.         local s, event = pcall(function()
  40.             return frame.MouseEnter;
  41.         end);
  42.  
  43.         if s then
  44.             frame.Active = true;
  45.  
  46.             event:connect(function()
  47.                 local input = frame.InputBegan:connect(function(key)
  48.                     if key.UserInputType == Enum.UserInputType.MouseButton1 then
  49.                         local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  50.                         while Heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  51.                             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, true);
  52.                         end;
  53.                     end;
  54.                 end);
  55.  
  56.                 local leave;
  57.                 leave = frame.MouseLeave:connect(function()
  58.                     input:disconnect();
  59.                     leave:disconnect();
  60.                 end)
  61.             end)
  62.         end
  63.     end
  64.  
  65.     function resizer.new(p, s)
  66.         p:GetPropertyChangedSignal('AbsoluteSize'):connect(function()
  67.             s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  68.         end)
  69.     end
  70. end;
  71.  
  72. function library:Create(class, props)
  73.     local object = Instance.new(class);
  74.    
  75.     for i, prop in next, props do
  76.         if i ~= "Parent" then
  77.             object[i] = prop;
  78.         end
  79.     end
  80.  
  81.     object.Parent = props.Parent;
  82.     return object;
  83. end
  84.  
  85.  
  86. function library:CreateWindow(options)
  87.     assert(options.text, "no name");
  88.     local window = {
  89.         count = 0;
  90.         toggles = {},
  91.         closed = false;
  92.     }
  93.  
  94.     local options = options or {};
  95.     setmetatable(options, {__index = defaults})
  96.  
  97.     self.windowcount = self.windowcount + 1;
  98.  
  99.     library.gui = library.gui or self:Create("ScreenGui", {Name = "Aztup's UI", Parent = game:GetService("Players").LocalPlayer.PlayerGui})
  100.     library.gui.ResetOnSpawn = false
  101.  
  102.     window.frame = self:Create("Frame", {
  103.         Name = options.text;
  104.         Parent = self.gui,
  105.         Visible = false,
  106.         Active = true,
  107.         BackgroundTransparency = 0,
  108.         Size = UDim2.new(0, 178, 0, 30),
  109.         Position = UDim2.new(0, (5 + ((178 * self.windowcount) - 178)), 0, 5),
  110.         BackgroundColor3 = options.barcolor,
  111.         BorderSizePixel = 0
  112.     });
  113.  
  114.     frames[#frames + 1] = window.frame;
  115.  
  116.     window.background = self:Create('Frame', {
  117.         Name = 'Background';
  118.         Parent = window.frame,
  119.         BorderSizePixel = 0;
  120.         BackgroundColor3 = options.bgcolor,
  121.         Position = UDim2.new(0, 0, 1, 0),
  122.         Size = UDim2.new(1, 0, 0, 25),
  123.         BackgroundTransparency = 0.4,
  124.         ClipsDescendants = true;
  125.     })
  126.  
  127.     window.container = self:Create('ScrollingFrame', {
  128.         Name = 'Container';
  129.         Parent = window.frame,
  130.         BorderSizePixel = 0,
  131.         BorderSizePixel = 0,
  132.         BackgroundColor3 = options.bgcolor,
  133.         CanvasSize = UDim2.new(0, 0, 0, 0),
  134.         BottomImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  135.         TopImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  136.         Position = UDim2.new(0, 0, 1, 0),
  137.         Size = UDim2.new(1, 0, 0, 25),
  138.         BackgroundTransparency = 0.4,
  139.         ClipsDescendants = true,
  140.         ScrollBarThickness = 10
  141.     })
  142.  
  143.     window.organizer = self:Create('UIListLayout', {
  144.         Name = 'Sorter';
  145.         SortOrder = Enum.SortOrder.LayoutOrder;
  146.         Parent = window.container;
  147.     })
  148.  
  149.     window.padder = self:Create('UIPadding', {
  150.         Name = 'Padding';
  151.         PaddingLeft = UDim.new(0, 10);
  152.         PaddingTop = UDim.new(0, 5);
  153.         Parent = window.container;
  154.     })
  155.  
  156.     local underline = self:Create("Frame", {
  157.         Name = 'Underline';
  158.         Size = UDim2.new(1, 0, 0, 3),
  159.         Position = UDim2.new(0, 0, 1, -1),
  160.         BorderSizePixel = 0;
  161.         BackgroundColor3 = options.underline;
  162.         Parent = window.frame
  163.     })
  164.  
  165.     local togglebutton = self:Create("TextButton", {
  166.         Name = 'Toggle';
  167.         ZIndex = 2,
  168.         BackgroundTransparency = 1;
  169.         Position = UDim2.new(1, -25, 0, 0),
  170.         Size = UDim2.new(0, 25, 1, 0),
  171.         Text = "-",
  172.         TextSize = 17,
  173.         TextColor3 = options.txtcolor,
  174.         Font = Enum.Font.SourceSans,
  175.         Parent = window.frame,
  176.     });
  177.  
  178.     togglebutton.MouseButton1Click:connect(function()
  179.         window.closed = not window.closed;
  180.         togglebutton.Text = (window.closed and "+" or "-");
  181.         if window.closed then
  182.             window:Resize(true, UDim2.new(1, 0, 0, 0));
  183.             wait(0.4)
  184.             window.container.Visible = false
  185.         else
  186.             window.container.Visible = true
  187.             window:Resize(true);
  188.         end;
  189.     end);
  190.  
  191.     self:Create("TextLabel", {
  192.         Size = UDim2.new(1, 0, 1, 0),
  193.         BackgroundTransparency = 1,
  194.         BorderSizePixel = 0,
  195.         TextColor3 = options.txtcolor,
  196.         TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255)),
  197.         TextSize = 17,
  198.         Font = Enum.Font.SourceSansSemibold,
  199.         Text = options.text or "window",
  200.         Name = "Window",
  201.         Parent = window.frame,
  202.     })
  203.  
  204.     local open = {}
  205.  
  206.     do
  207.         dragger.new(window.frame)
  208.         resizer.new(window.background, window.container);
  209.     end
  210.  
  211.     local function getSize()
  212.         local ySize = 0;
  213.         for i, object in next, window.container:GetChildren() do
  214.             if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  215.                 ySize = ySize + object.AbsoluteSize.Y
  216.             end
  217.         end
  218.        
  219.         if ySize > 400 then
  220.             ySize = 400;
  221.             window.container.CanvasSize = UDim2.new(0, 0, 0, (#window.container:GetChildren() - 1) * 20)
  222.         end;
  223.        
  224.         return UDim2.new(1, 0, 0, ySize + 10)
  225.     end
  226.  
  227.     function window:Resize(tween, change)
  228.         local size = change or getSize()
  229.         self.container.ClipsDescendants = true;
  230.  
  231.         if tween then
  232.             self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  233.         else
  234.             self.background.Size = size
  235.         end
  236.     end
  237.  
  238.     function window:AddSlidingBar(text, minval, maxval, callback)
  239.         self.count = self.count + 1;
  240.         callback = callback or function() end;
  241.         minval = minval or 0;
  242.         maxval = maxval or 100;
  243.  
  244.         maxval = maxval / 8;
  245.        
  246.         local newContainer = library:Create("Frame", {
  247.             Parent = self.container,
  248.             Size = UDim2.new(1, -10, 0, 20),
  249.             BackgroundColor3 = options.slidingbarcolor,
  250.             BackgroundTransparency = 1,
  251.         })
  252.  
  253.         local slidingbar = library:Create("ScrollingFrame", {
  254.             Parent = newContainer,
  255.             Size = UDim2.new(1, -10, 0, 20),
  256.             CanvasSize = UDim2.new(8, 0, 0, 0),
  257.             BackgroundColor3 = options.slidingbarcolor,
  258.             BottomImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  259.             TopImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  260.             MidImage = "rbxasset://textures/ui/Scroll/scroll-middle.png",
  261.             ScrollBarThickness = 20,
  262.             ScrollBarImageColor3 = Color3.fromRGB(0, 0, 0),
  263.             ScrollBarImageTransparency = 0.3,
  264.         });
  265.  
  266.         local label = library:Create("TextLabel", {
  267.             Size = UDim2.new(1, 0, 1, 0),
  268.             BackgroundTransparency = 1,
  269.             BackgroundColor3 = options.slidingbarcolor,
  270.             TextColor3 = Color3.fromRGB(255, 255, 255),
  271.             TextXAlignment = Enum.TextXAlignment.Center,
  272.             TextSize = 16,
  273.             Text = text .. ": " .. minval,
  274.             Font = Enum.Font.SourceSans,
  275.             LayoutOrder = self.Count,
  276.             BorderSizePixel = 0,
  277.             Parent = newContainer,
  278.         })
  279.  
  280.         slidingbar.Changed:Connect(function(p)
  281.             if p ~= "CanvasPosition" then return end
  282.  
  283.             local Val = minval - math.floor((slidingbar.CanvasPosition.X / (slidingbar.CanvasSize.X.Offset - slidingbar.AbsoluteWindowSize.X)) * maxval)
  284.             label.Text = text .. ": " .. tostring(Val);
  285.             callback(Val);
  286.         end)
  287.  
  288.         self:Resize();
  289.  
  290.     end;
  291.  
  292.     function window:AddToggle(text, callback)
  293.         self.count = self.count + 1;
  294.  
  295.         callback = callback or function() end;
  296.  
  297.         local label = library:Create("TextLabel", {
  298.             Text =  text,
  299.             Size = UDim2.new(1, -10, 0, 20),
  300.             BackgroundTransparency = 1,
  301.             TextColor3 = Color3.fromRGB(255, 255, 255),
  302.             TextXAlignment = Enum.TextXAlignment.Left,
  303.             LayoutOrder = self.Count,
  304.             TextSize = 16,
  305.             Font = Enum.Font.SourceSans,
  306.             Parent = self.container,
  307.         })
  308.  
  309.         local button = library:Create("TextButton", {
  310.             Text = "OFF",
  311.             TextColor3 = Color3.fromRGB(255, 25, 25),
  312.             BackgroundTransparency = 1,
  313.             Position = UDim2.new(1, -25, 0, 0),
  314.             Size = UDim2.new(0, 25, 1, 0),
  315.             TextSize = 17,
  316.             Font = Enum.Font.SourceSansSemibold,
  317.             Parent = label,
  318.         })
  319.  
  320.         Callbacks[text] = function(toggle)
  321.             if not toggle then
  322.                 toggle = not self.toggles[text];
  323.             end;
  324.  
  325.             self.toggles[text] = toggle;
  326.             Enabled[text] = toggle;
  327.             button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25));
  328.             button.Text = (self.toggles[text] and "ON" or "OFF");
  329.  
  330.             callback(self.toggles[text]);
  331.         end;
  332.  
  333.         button.MouseButton1Click:connect(Callbacks[text]);
  334.  
  335.         self:Resize();
  336.         return button;
  337.     end
  338.  
  339.     function window:AddBox(text, callback)
  340.         self.count = self.count + 1
  341.         callback = callback or function() end
  342.  
  343.         local box = library:Create("TextBox", {
  344.             PlaceholderText = text,
  345.             Size = UDim2.new(1, -10, 0, 20),
  346.             BackgroundTransparency = 0.75,
  347.             BackgroundColor3 = options.boxcolor,
  348.             TextColor3 = Color3.fromRGB(255, 255, 255),
  349.             TextXAlignment = Enum.TextXAlignment.Center,
  350.             TextSize = 16,
  351.             Text = "",
  352.             Font = Enum.Font.SourceSans,
  353.             LayoutOrder = self.Count,
  354.             BorderSizePixel = 0,
  355.             Parent = self.container,
  356.         })
  357.  
  358.         box.FocusLost:connect(function(...)
  359.             callback(box, ...)
  360.         end)
  361.  
  362.         self:Resize()
  363.         return box
  364.     end
  365.  
  366.     function window:AddButton(text, callback)
  367.         self.count = self.count + 1
  368.  
  369.         callback = callback or function() end
  370.        
  371.         local button = library:Create("TextButton", {
  372.             Text = text,
  373.             Size = UDim2.new(1, -10, 0, 20),
  374.             BackgroundTransparency = 1,
  375.             TextColor3 = Color3.fromRGB(255, 255, 255),
  376.             TextXAlignment = Enum.TextXAlignment.Left,
  377.             TextSize = 16,
  378.             Font = Enum.Font.SourceSans,
  379.             LayoutOrder = self.Count,
  380.             Parent = self.container,
  381.         })
  382.  
  383.         button.MouseButton1Click:connect(callback)
  384.         self:Resize()
  385.         return button
  386.     end
  387.  
  388.     function window:AddLabel(text)
  389.         self.count = self.count + 1;
  390.  
  391.         local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  392.  
  393.         local button = library:Create("TextLabel", {
  394.             Text =  text,
  395.             Size = UDim2.new(1, -10, 0, tSize.Y + 5),
  396.             TextScaled = false,
  397.             BackgroundTransparency = 1,
  398.             TextColor3 = Color3.fromRGB(255, 255, 255),
  399.             TextXAlignment = Enum.TextXAlignment.Left,
  400.             TextSize = 16,
  401.             Font = Enum.Font.SourceSans,
  402.             LayoutOrder = self.Count,
  403.             Parent = self.container,
  404.         });
  405.  
  406.         self:Resize();
  407.         return button;
  408.     end;
  409.  
  410.     function window:AddDropdown(options, callback)
  411.         self.count = self.count + 1
  412.         local default = options[1] or "";
  413.  
  414.         callback = callback or function() end
  415.         local dropdown = library:Create("TextLabel", {
  416.             Size = UDim2.new(1, -10, 0, 20),
  417.             BackgroundTransparency = 0.75,
  418.             BackgroundColor3 = options.boxcolor,
  419.             TextColor3 = Color3.fromRGB(255, 255, 255),
  420.             TextXAlignment = Enum.TextXAlignment.Center,
  421.             TextSize = 16,
  422.             Text = default,
  423.             Font = Enum.Font.SourceSans,
  424.             BorderSizePixel = 0;
  425.             LayoutOrder = self.Count,
  426.             Parent = self.container,
  427.         })
  428.  
  429.         local button = library:Create("ImageButton",{
  430.             BackgroundTransparency = 1,
  431.             Image = 'rbxassetid://3234893186',
  432.             Size = UDim2.new(0, 18, 1, 0),
  433.             Position = UDim2.new(1, -20, 0, 0),
  434.             Parent = dropdown,
  435.         })
  436.  
  437.         local frame;
  438.  
  439.         local function isInGui(frame)
  440.             local mloc = game:GetService('UserInputService'):GetMouseLocation();
  441.             local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  442.  
  443.             local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  444.             local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  445.  
  446.             return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2);
  447.         end;
  448.  
  449.         local function count(t)
  450.             local c = 0;
  451.             for i, v in next, t do
  452.                 c = c + 1;
  453.             end;
  454.             return c;
  455.         end;
  456.  
  457.         button.MouseButton1Click:connect(function()
  458.             if count(options) == 0 then
  459.                 return;
  460.             end;
  461.  
  462.             if frame then
  463.                 frame:Destroy();
  464.                 frame = nil;
  465.             end
  466.  
  467.             self.container.ClipsDescendants = false;
  468.  
  469.             frame = library:Create('Frame', {
  470.                 Position = UDim2.new(0, 0, 1, 0);
  471.                 BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  472.                 Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  473.                 BorderSizePixel = 0;
  474.                 Parent = dropdown;
  475.                 ClipsDescendants = true;
  476.                 ZIndex = 2;
  477.             })
  478.  
  479.             library:Create('UIListLayout', {
  480.                 Name = 'Layout';
  481.                 Parent = frame;
  482.             })
  483.  
  484.             for i, option in next, options do
  485.                 local selection = library:Create('TextButton', {
  486.                     Text = option;
  487.                     BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  488.                     TextColor3 = Color3.fromRGB(255, 255, 255);
  489.                     BorderSizePixel = 0;
  490.                     TextSize = 16;
  491.                     Font = Enum.Font.SourceSans;
  492.                     Size = UDim2.new(1, 0, 0, 21);
  493.                     Parent = frame;
  494.                     ZIndex = 2;
  495.                 })
  496.  
  497.                 selection.MouseButton1Click:connect(function()
  498.                     dropdown.Text = option;
  499.                     callback(option);
  500.                     frame.Size = UDim2.new(1, 0, 0, 0);
  501.                     game:GetService('Debris'):AddItem(frame, 0.1);
  502.                 end);
  503.             end;
  504.         end);
  505.  
  506.         game:GetService('UserInputService').InputBegan:connect(function(m)
  507.             if m.UserInputType == Enum.UserInputType.MouseButton1 then
  508.                 if frame and (not isInGui(frame)) then
  509.                     game:GetService('Debris'):AddItem(frame);
  510.                 end
  511.             end
  512.         end)
  513.  
  514.         callback(default);
  515.         self:Resize();
  516.         return {
  517.             Refresh = function(self, array)
  518.                 game:GetService('Debris'):AddItem(frame);
  519.                 options = array;
  520.                 dropdown.Text = options[1];
  521.             end;
  522.         };
  523.     end;
  524.  
  525.     return window;
  526. end;
  527.  
  528. if defaults.Rainbow then
  529.     Heartbeat:Connect(function()
  530.         for i, v in pairs(frames) do
  531.             if v.Parent ~= nil then
  532.                 local r = (math.sin(workspace.DistributedGameTime/2)/2)+0.5
  533.                 local g = (math.sin(workspace.DistributedGameTime)/2)+0.5
  534.                 local b = (math.sin(workspace.DistributedGameTime*1.5)/2)+0.5
  535.                 local color = Color3.new(r, g, b);
  536.                 v.Underline.BackgroundColor3 = color;
  537.             end;
  538.         end;
  539.     end);
  540. end;
  541.  
  542. return library, frames, Callbacks, Enabled
Add Comment
Please, Sign In to add comment