Advertisement
Inqxii

Application Script

Mar 25th, 2023
2,019
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.95 KB | None | 0 0
  1. local players = game:GetService("Players")
  2. local lPlr = players.LocalPlayer
  3. local plrGui = lPlr.PlayerGui
  4. local mainV2 = plrGui:WaitForChild("MainV2")
  5. local button = require(script.Parent:WaitForChild("Button"))
  6.  
  7. local buttonGradients = {
  8.     ["Obbies"] = ColorSequence.new{
  9.         ColorSequenceKeypoint.new(0, Color3.fromRGB(144, 17, 255)),
  10.         ColorSequenceKeypoint.new(1, Color3.fromRGB(216, 21, 255))
  11.     };
  12.     ["Default"] = ColorSequence.new{
  13.         ColorSequenceKeypoint.new(0, Color3.fromRGB(46, 46, 46)),
  14.         ColorSequenceKeypoint.new(1, Color3.fromRGB(12, 12, 12)),
  15.     }
  16. }
  17.  
  18.  
  19. local sideButton = {}
  20. sideButton.__index = sideButton
  21. local hoveredButtons = {}
  22. local state = "default"
  23. local rightLine = mainV2.SideButtons.RightSideLine
  24. local focusedButton = mainV2.SideButtons.Buttons.FocusedButton
  25. local toggledButton = nil
  26. local buttons = {}
  27.  
  28. function sideButton._reformatSidePanel()
  29.     print("Called")
  30.     print(state.." "..tostring(hoveredButtons))
  31.     if state == "default" and #hoveredButtons == 0 then -- Moves everything back to the default format
  32.         print("Moving")
  33.         for i, v in pairs(buttons) do
  34.             v.toggled = false
  35.             v.inst.Position = v.origPos
  36.         end
  37.         rightLine:TweenPosition(UDim2.new(0.4575, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.1, true)
  38.     end
  39. end
  40.  
  41.  
  42.  
  43. function sideButton.new(name: string, inst: Instance, frame : table)
  44.     if not buttonGradients[name] then
  45.         warn("UI Error: Button gradient not found")
  46.         return "Error"
  47.     end
  48.     if not inst then
  49.         warn("UI Error: Instance not passed or nil")
  50.         return "Error"
  51.     end
  52.     local newButton = {}
  53.     setmetatable(newButton, sideButton)
  54.  
  55.     newButton.frame = frame or nil
  56.     newButton.name = name
  57.     newButton.inst = inst
  58.     newButton.buttonType = "SideButton"
  59.     newButton.origPos = inst.Position
  60.     newButton.hoverPos = UDim2.new(inst.Position.X.Scale + 0.05, 0, inst.Position.Y.Scale, 0)
  61.     newButton.debounce = false
  62.     newButton.toggled = false
  63.     newButton.focus = focusedButton:Clone()
  64.     newButton.focus.Parent = mainV2.SideButtons.Buttons
  65.     newButton.focus.Position = newButton.origPos
  66.     newButton.focus.TextLabel.Text = name
  67.     newButton.gradient = buttonGradients[name]
  68.  
  69.     -- frame:linkToButton(newButton)
  70.  
  71.     newButton.inst.MouseEnter:Connect(function()
  72.         table.insert(hoveredButtons, newButton)
  73.         newButton.inst:TweenPosition(newButton.hoverPos, Enum.EasingDirection.In, Enum.EasingStyle.Quart, 0.2)
  74.         if state ~= "toggled" or #hoveredButtons == 1 then
  75.             rightLine:TweenPosition(UDim2.new(0.85, 0, 0.5, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quart, 0.2, true)
  76.         end
  77.         if newButton.toggled ~= true then
  78.             newButton.focus.Size = UDim2.new(0, 0, 0.144, 0)
  79.         end
  80.        
  81.         newButton.focus.Visible = true
  82.         newButton.focus.Position = newButton.hoverPos
  83.         newButton.focus:TweenSize(UDim2.new(0.55, 0, 0.144, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quart, 0.2, true)
  84.     end)
  85.     newButton.inst.MouseLeave:Connect(function()
  86.         if newButton.toggled == false then
  87.             newButton.inst:TweenPosition(newButton.origPos, Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.15, true)
  88.             newButton.focus:TweenSize(UDim2.new(0, 0, 0.144, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.15, true)
  89.             newButton.focus:TweenPosition(newButton.origPos, Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.15, true)
  90.         end
  91.         if #hoveredButtons == 1 then
  92.             print("Reformat conditions..")
  93.             hoveredButtons = {}
  94.             if state == "toggled" then
  95.                 print("Toggled")
  96.             else
  97.                 print("Formatting")
  98.                 sideButton._reformatSidePanel()
  99.             end
  100.         end
  101.     end)
  102.  
  103.     newButton.inst.MouseButton1Click:Connect(function()
  104.         if state == "toggled" then
  105.             if toggledButton == newButton then
  106.                 newButton.toggled = false
  107.                 state = "default"
  108.                 toggledButton = nil
  109.                 rightLine.UIGradient.Color = buttonGradients["Default"]
  110.                 newButton.frame:close()
  111.                 return
  112.             end
  113.             newButton.toggled = true
  114.             toggledButton.toggled = false
  115.             toggledButton = newButton
  116.             rightLine.UIGradient.Color = newButton.gradient
  117.             newButton.frame:switchTo()
  118.         else
  119.             state = "toggled"
  120.             toggledButton = newButton
  121.             newButton.toggled = true
  122.             rightLine.UIGradient.Color = newButton.gradient
  123.             newButton.frame:open()
  124.         end
  125.     end)
  126.     button.new(true, false, inst, nil, {style = Enum.EasingStyle.Quart, direction = Enum.EasingDirection.In, tweenTime = 0.1}, name)
  127.     table.insert(buttons, newButton)
  128.     return newButton
  129.  
  130. end
  131.  
  132.  
  133.  
  134.  
  135.  
  136. return sideButton
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement