Advertisement
XZTablets

GradientFlatUILib

Apr 6th, 2020
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.62 KB | None | 0 0
  1. local gs = loadstring(game:HttpGet("https://pastebin.com/raw/pKUmK76B"))()
  2. local player = game.Players.LocalPlayer
  3. local mouse = player:GetMouse()
  4. local inputService = game:GetService("UserInputService")
  5. local tweenService = game:GetService("TweenService")
  6.  
  7. function getXY(guiObject)
  8.     local x, y = mouse.X - guiObject.AbsolutePosition.X, mouse.Y - guiObject.AbsolutePosition.Y
  9.     local xMax, yMax = guiObject.AbsoluteSize.X, guiObject.AbsoluteSize.Y
  10.     x = math.clamp(x, 0, xMax)
  11.     y = math.clamp(y, 0, yMax)
  12.     return x, y, x/xMax, y/yMax
  13. end
  14.  
  15. local library = {}
  16.  
  17. function library:Create(clips, name, toggle)
  18.     local clips = clips or true
  19.     local name = name or "xJDiviisionZ UI Lib"
  20.     local toggle = toggle or "Q"
  21.     local keyCode = Enum.KeyCode[toggle]
  22.    
  23.     local in_view = false
  24.     local dragging = false
  25.     local lastmousex, lastmousey
  26.    
  27.     local gui
  28.     local container
  29.     local renderbar
  30.     local titlebar
  31.     local options
  32.     local main
  33.    
  34.     gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
  35.     gui.Name = name
  36.     gui.ZIndexBehavior = Enum.ZIndexBehavior.Global
  37.    
  38.     container = Instance.new("Frame")
  39.     container.Name = "Container"
  40.     container.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  41.     container.BorderSizePixel = 0
  42.     container.Size = UDim2.new(0, 498, 0, 240)
  43.     container.Position = UDim2.new(0.5, -249, 0.5, -120)
  44.     container.Parent = gui
  45.    
  46.     renderbar = Instance.new("Frame")
  47.     renderbar.Name = "RenderBar"
  48.     renderbar.BackgroundTransparency = 1
  49.     renderbar.Size = UDim2.new(1, 0, 0, 10)
  50.     renderbar.Parent = container
  51.    
  52.     gs:RenderGradient(renderbar, 6)
  53.    
  54.     titlebar = Instance.new("Frame")
  55.     titlebar.Name = "TitleBar"
  56.     titlebar.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  57.     titlebar.BorderSizePixel = 0
  58.     titlebar.Size = UDim2.new(1, 0, 0, 30)
  59.     titlebar.Position = UDim2.new(0, 0, 0, 10)
  60.     titlebar.Parent = container
  61.    
  62.     gs:TextGradient(titlebar, name, 18, Enum.Font.SourceSansBold, Color3.fromRGB(255, 255, 255), Color3.fromRGB(255, 255, 255))
  63.    
  64.     options = Instance.new("Frame")
  65.     options.Name = "Options"
  66.     options.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  67.     options.BorderSizePixel = 0
  68.     options.Size = UDim2.new(0, 100, 0, 200)
  69.     options.Position = UDim2.new(0, 0, 0, 40)
  70.     options.Parent = container
  71.    
  72.     main = Instance.new("Frame")
  73.     main.Name = "Main"
  74.     main.BackgroundTransparency = 1
  75.     main.Size = UDim2.new(0, 398, 0, 200)
  76.     main.Position = UDim2.new(0, 100, 0, 40)
  77.     main.Parent = container
  78.    
  79.     titlebar.MouseEnter:Connect(function()
  80.         in_view = true
  81.     end)
  82.        
  83.     titlebar.MouseLeave:Connect(function()
  84.         in_view = false
  85.     end)
  86.        
  87.     mouse.Button1Down:Connect(function()
  88.         if in_view then
  89.             lastmousex = mouse.X
  90.             lastmousey = mouse.Y
  91.             dragging = true
  92.         end
  93.     end)
  94.        
  95.     mouse.Button1Up:Connect(function()
  96.         dragging = false
  97.     end)
  98.    
  99.     spawn(function()
  100.         while wait(0.1) do
  101.             if dragging then
  102.                 local x, y = mouse.X, mouse.Y
  103.                 local deltaX, deltaY = x - lastmousex, y - lastmousey
  104.                 container:TweenPosition(container.Position + UDim2.new(0, deltaX, 0, deltaY), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
  105.                 lastmousex = x
  106.                 lastmousey = y
  107.             end
  108.         end
  109.     end)
  110.    
  111.     local optionsLib = {}
  112.     local n_options = 0
  113.    
  114.     function optionsLib:AddOption(option)
  115.         local textButton = Instance.new("TextButton")
  116.         textButton.Name = option
  117.         textButton.BackgroundTransparency = 1
  118.         textButton.Size = UDim2.new(1, 0, 0, 30)
  119.         textButton.Text = "   " .. tostring(option)
  120.         textButton.Font = Enum.Font.SourceSansBold
  121.         textButton.TextSize = 20
  122.         textButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  123.         textButton.Position = UDim2.new(0, 0, 0, n_options * 30)
  124.         textButton.TextXAlignment = Enum.TextXAlignment.Left
  125.         textButton.Parent = options
  126.        
  127.         local optionContainer = Instance.new("ScrollingFrame")
  128.         optionContainer.TopImage = "http://www.roblox.com/asset/?id=4812947"
  129.         optionContainer.BottomImage = "http://www.roblox.com/asset/?id=4812947"
  130.         optionContainer.MidImage = "http://www.roblox.com/asset/?id=4812947"
  131.         optionContainer.ScrollBarImageColor3 = Color3.fromRGB(255, 36, 134)
  132.         optionContainer.BorderSizePixel = 0
  133.         optionContainer.ScrollingDirection = Enum.ScrollingDirection.Y
  134.         optionContainer.Name = option
  135.         optionContainer.Size = UDim2.new(1, 0, 1, 0)
  136.         optionContainer.BackgroundTransparency = 1
  137.         optionContainer.Parent = main
  138.        
  139.         local optionPadding = Instance.new("UIPadding")
  140.         optionPadding.PaddingTop = UDim.new(0, 5)
  141.         optionPadding.PaddingLeft = UDim.new(0, -15)
  142.         optionPadding.Parent = optionContainer
  143.        
  144.         local optionListLayout = Instance.new("UIListLayout")
  145.         optionListLayout.Padding = UDim.new(0, 5)
  146.         optionListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  147.         optionListLayout.Parent = optionContainer
  148.         optionListLayout.SortOrder = Enum.SortOrder.LayoutOrder
  149.        
  150.         if n_options == 0 then
  151.             gs:RectGradient(textButton, textButton.AbsoluteSize.X, 30)
  152.             optionContainer.Visible = true
  153.         else
  154.             optionContainer.Visible = false
  155.         end
  156.        
  157.         n_options = n_options + 1
  158.        
  159.         textButton.MouseButton1Down:Connect(function()
  160.             for i,v in pairs(options:GetChildren()) do
  161.                 gs:ClearGradient(v)
  162.             end
  163.             for i,v in pairs(main:GetChildren()) do
  164.                 v.Visible = false
  165.             end
  166.             gs:RectGradient(textButton, textButton.AbsoluteSize.X, 30)
  167.             main[option].Visible = true
  168.         end)
  169.            
  170.         local guiLib = {}
  171.        
  172.         function guiLib:AddButton(text, callback)
  173.             local button = Instance.new("TextButton")
  174.             button.Name = text:sub(1, 3):lower().."BTN"
  175.             button.BorderSizePixel = 0
  176.             button.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  177.             button.Size = UDim2.new(0, 375, 0, 20)
  178.             button.Font = Enum.Font.SourceSansBold
  179.             button.Text = text
  180.             button.TextSize = 20
  181.             button.TextColor3 = Color3.fromRGB(255, 255, 255)
  182.             button.Parent = optionContainer
  183.            
  184.             gs:RectGradient(button, 375, 20)
  185.            
  186.             button.MouseButton1Down:Connect(function()
  187.                 callback()
  188.             end)
  189.         end
  190.        
  191.         function guiLib:AddSlider(text, min, max, callback)
  192.             local value = min
  193.             local min = min
  194.             local max = max
  195.            
  196.             local sliderContainer = Instance.new("Frame")
  197.             sliderContainer.Name = text:sub(1, 3):lower().."SLD"
  198.             sliderContainer.BorderSizePixel = 0
  199.             sliderContainer.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  200.             sliderContainer.Size = UDim2.new(0, 375, 0, 40)
  201.             sliderContainer.Parent = optionContainer
  202.            
  203.             local sliderButton = Instance.new("TextButton")
  204.             sliderButton.Name = "SliderButton"
  205.             sliderButton.Text = ""
  206.             sliderButton.AutoButtonColor = false
  207.             sliderButton.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  208.             sliderButton.BorderSizePixel = 0
  209.             sliderButton.Size = UDim2.new(1, 0, 0, 5)
  210.             sliderButton.Position = UDim2.new(0, 0, 1, -5)
  211.             sliderButton.Parent = sliderContainer
  212.            
  213.             local sliderText = Instance.new("TextLabel")
  214.             sliderText.BackgroundTransparency = 1
  215.             sliderText.Size = UDim2.new(0, 375, 0, 35)
  216.             sliderText.Text = (text .. ": " .. tostring(value))
  217.             sliderText.Font = Enum.Font.SourceSansBold
  218.             sliderText.TextColor3 = Color3.fromRGB(255, 255, 255)
  219.             sliderText.TextSize = 20
  220.             sliderText.Parent = sliderContainer
  221.            
  222.             gs:RectGradient(sliderContainer, 375, 40)
  223.            
  224.             callback(value)
  225.            
  226.             sliderButton.MouseButton1Down:Connect(function()
  227.                 local x, y, scalex, scaley = getXY(sliderButton)
  228.                 gs:SliderGradient(sliderButton, {Max = 375, Current = x, Size = 1})
  229.                 local newValue = math.floor((min + ((max - min) * scalex)))
  230.                 sliderText.Text = (text .. ": " .. tostring(newValue))
  231.                 callback(newValue)
  232.                 local move = mouse.Move:Connect(function()
  233.                     local x, y, scalex, scaley = getXY(sliderButton)
  234.                     gs:SliderGradient(sliderButton, {Max = 375, Current = x, Size = 1})
  235.                     local newValue = math.floor((min + ((max - min) * scalex)))
  236.                     sliderText.Text = (text .. ": " .. tostring(newValue))
  237.                     callback(newValue)
  238.                 end)
  239.                 inputService.InputEnded:Connect(function(check)
  240.                     if check.UserInputType == Enum.UserInputType.MouseButton1 then
  241.                         move:Disconnect()
  242.                     end
  243.                 end)
  244.             end)
  245.         end
  246.        
  247.         function guiLib:AddToggle(text, default, callback)
  248.             local uiToggle = default
  249.            
  250.             local disColourOne = Color3.fromRGB(184, 0, 31)
  251.             local disColourTwo = Color3.fromRGB(184, 0, 31)
  252.            
  253.             local enbColourOne = Color3.fromRGB(0, 196, 17)
  254.             local enbColourTwo = Color3.fromRGB(0, 196, 17)
  255.            
  256.             local toggleContainer = Instance.new("Frame")
  257.             toggleContainer.Name = text:sub(1,3):lower().."TGL"
  258.             toggleContainer.BackgroundTransparency = 1
  259.             toggleContainer.Size = UDim2.new(0, 375, 0, 20)
  260.             toggleContainer.Parent = optionContainer
  261.            
  262.             local toggleButton = Instance.new("TextButton")
  263.             toggleButton.Text = text
  264.             toggleButton.Font = Enum.Font.SourceSansBold
  265.             toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  266.             toggleButton.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  267.             toggleButton.BorderSizePixel = 0
  268.             toggleButton.TextSize = 20
  269.             toggleButton.Size = UDim2.new(0, 351, 1, 0)
  270.             toggleButton.Parent = toggleContainer
  271.            
  272.             local toggleFrame = Instance.new("Frame")
  273.             toggleFrame.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  274.             toggleFrame.BorderSizePixel = 0
  275.             toggleFrame.Size = UDim2.new(0, 20, 0, 20)
  276.             toggleFrame.Position = UDim2.new(1, -20, 0, 0)
  277.             toggleFrame.Parent = toggleContainer
  278.            
  279.             gs:RectGradient(toggleButton, 351, 20)
  280.            
  281.             local function update()
  282.                 if uiToggle then
  283.                     gs:RectGradient(toggleFrame, 20, 20, enbColourOne, enbColourTwo)
  284.                 else
  285.                     gs:RectGradient(toggleFrame, 20, 20, disColourOne, disColourTwo)
  286.                 end
  287.             end
  288.            
  289.             update()
  290.             callback(uiToggle)
  291.            
  292.             toggleButton.MouseButton1Down:Connect(function()
  293.                 uiToggle = not uiToggle
  294.                 update()
  295.                 callback(uiToggle)
  296.             end)
  297.         end
  298.        
  299.         function guiLib:AddDropdown(text, optionTable, callback)
  300.             local nOptions = #optionTable
  301.             local open = false
  302.            
  303.             local dropContainer = Instance.new("Frame")
  304.             dropContainer.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  305.             dropContainer.BorderSizePixel = 0
  306.             dropContainer.Size = UDim2.new(0, 375, 0, 20)
  307.             dropContainer.Parent = optionContainer
  308.            
  309.             local tableContainer = Instance.new("Frame")
  310.             tableContainer.BackgroundColor3 = Color3.fromRGB(24, 24, 24)
  311.             tableContainer.BorderSizePixel = 0
  312.             tableContainer.Position = UDim2.new(0, 0, 0, 20)
  313.             tableContainer.Size = UDim2.new(0, 375, 0, 0)
  314.             tableContainer.ClipsDescendants = true
  315.             tableContainer.Parent = dropContainer
  316.            
  317.             local tableLayout = Instance.new("UIListLayout")
  318.             tableLayout.SortOrder = Enum.SortOrder.LayoutOrder
  319.             tableLayout.Parent = tableContainer
  320.            
  321.             local dropStatus = Instance.new("ImageButton")
  322.             dropStatus.BackgroundTransparency = 1
  323.             dropStatus.Size = UDim2.new(0, 20, 0, 20)
  324.             dropStatus.Image = "http://www.roblox.com/asset/?id=71659683"
  325.             dropStatus.Parent = dropContainer
  326.            
  327.             local dropText = Instance.new("TextLabel")
  328.             dropText.BackgroundTransparency = 1
  329.             dropText.Size = UDim2.new(1, 0, 0, 20)
  330.             dropText.Font = Enum.Font.SourceSansBold
  331.             dropText.Text = text
  332.             dropText.TextColor3 = Color3.fromRGB(255, 255, 255)
  333.             dropText.TextSize = 20
  334.             dropText.Parent = dropContainer
  335.            
  336.             for i,v in pairs(optionTable) do
  337.                 local dropButton = Instance.new("TextButton")
  338.                 dropButton.BackgroundColor3 = Color3.fromRGB(24, 24, 24)
  339.                 dropButton.BorderSizePixel = 0
  340.                 dropButton.Size = UDim2.new(0, 375, 0, 20)
  341.                 dropButton.Font = Enum.Font.SourceSansBold
  342.                 dropButton.Text = v
  343.                 dropButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  344.                 dropButton.TextSize = 20
  345.                 dropButton.ZIndex = 2
  346.                 dropButton.Parent = tableContainer
  347.                 gs:RectGradient(dropButton, 375, 20)
  348.                 dropButton.MouseButton1Down:Connect(function()
  349.                     callback(v)
  350.                 end)
  351.             end
  352.            
  353.             gs:RectGradient(dropContainer, 375, 20)
  354.            
  355.             dropStatus.MouseButton1Down:Connect(function()
  356.                 open = not open
  357.                 if open then
  358.                     tweenService:Create(dropStatus, TweenInfo.new(0.5), {Rotation = 90}):Play()
  359.                     tableContainer:TweenSize(UDim2.new(0, 375, 0, nOptions * 20), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
  360.                     dropContainer:TweenSize(UDim2.new(0, 375, 0, (nOptions + 1) * 20), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
  361.                 else
  362.                     tweenService:Create(dropStatus, TweenInfo.new(0.5), {Rotation = 0}):Play()
  363.                     tableContainer:TweenSize(UDim2.new(0, 375, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
  364.                     dropContainer:TweenSize(UDim2.new(0, 375, 0, 20), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5, true)
  365.                 end
  366.             end)
  367.         end
  368.        
  369.         function guiLib:AddInput(text, callback)
  370.             local inputFrame = Instance.new("Frame")
  371.             inputFrame.BackgroundColor3 = Color3.fromRGB(17, 17, 17)
  372.             inputFrame.Size = UDim2.new(0, 375, 0, 20)
  373.             inputFrame.BorderSizePixel = 0
  374.             inputFrame.Parent = optionContainer
  375.            
  376.             gs:RectGradient(inputFrame, 375, 20)
  377.            
  378.             local inputLabel = Instance.new("TextLabel")
  379.             inputLabel.BackgroundTransparency = 1
  380.             inputLabel.Size = UDim2.new(0, 192, 0, 20)
  381.             inputLabel.Font = Enum.Font.SourceSansBold
  382.             inputLabel.Text = text
  383.             inputLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  384.             inputLabel.TextSize = 20
  385.             inputLabel.Parent = inputFrame
  386.            
  387.             local inputBox = Instance.new("TextBox")
  388.             inputBox.Position = UDim2.new(0.5, 0, 0, 0)
  389.             inputBox.Size = UDim2.new(0.5, 0, 1, 0)
  390.             inputBox.Font = Enum.Font.SourceSansBold
  391.             inputBox.Text = ""
  392.             inputBox.TextColor3 = Color3.fromRGB(255, 255, 255)
  393.             inputBox.BackgroundColor3 = Color3.fromRGB(24, 24, 24)
  394.             inputBox.BorderSizePixel = 0
  395.             inputBox.TextSize = 18
  396.             inputBox.Parent = inputFrame
  397.            
  398.             inputBox.FocusLost:Connect(function()
  399.                 callback(inputBox.Text)
  400.             end)
  401.         end
  402.        
  403.         return guiLib
  404.     end
  405.     return optionsLib
  406. end
  407.  
  408. return library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement