Steamhesaproblox

Roblox Dex Explorerscript

May 17th, 2025
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RBScript 410.32 KB | Gaming | 0 0
  1. -- https://github.com/LorekeeperZinnia/Dex
  2.  
  3. --[[
  4.     New Dex
  5.     Final Version
  6.     Developed by Moon
  7.     Modified for Infinite Yield
  8.    
  9.     Dex is a debugging suite designed to help the user debug games and find any potential vulnerabilities.
  10. ]]
  11.  
  12. local nodes = {}
  13. local selection
  14. local cloneref = cloneref or function(...) return ... end
  15.  
  16. local EmbeddedModules = {
  17. Explorer = function()
  18. --[[
  19.     Explorer App Module
  20.    
  21.     The main explorer interface
  22. ]]
  23.  
  24. -- Common Locals
  25. local Main,Lib,Apps,Settings -- Main Containers
  26. local Explorer, Properties, ScriptViewer, Notebook -- Major Apps
  27. local API,RMD,env,service,plr,create,createSimple -- Main Locals
  28.  
  29. local function initDeps(data)
  30.     Main = data.Main
  31.     Lib = data.Lib
  32.     Apps = data.Apps
  33.     Settings = data.Settings
  34.  
  35.     API = data.API
  36.     RMD = data.RMD
  37.     env = data.env
  38.     service = data.service
  39.     plr = data.plr
  40.     create = data.create
  41.     createSimple = data.createSimple
  42. end
  43.  
  44. local function initAfterMain()
  45.     Explorer = Apps.Explorer
  46.     Properties = Apps.Properties
  47.     ScriptViewer = Apps.ScriptViewer
  48.     Notebook = Apps.Notebook
  49. end
  50.  
  51. local function main()
  52.     local Explorer = {}
  53.     local tree,listEntries,explorerOrders,searchResults,specResults = {},{},{},{},{}
  54.     local expanded
  55.     local entryTemplate,treeFrame,toolBar,descendantAddedCon,descendantRemovingCon,itemChangedCon
  56.     local ffa = game["Run Service"].Parent.FindFirstAncestorWhichIsA
  57.     local getDescendants = game["Run Service"].Parent.GetDescendants
  58.     local getTextSize = service.TextService.GetTextSize
  59.     local updateDebounce,refreshDebounce = false,false
  60.     local nilNode = {Obj = Instance.new("Folder")}
  61.     local idCounter = 0
  62.     local scrollV,scrollH,clipboard
  63.     local renameBox,renamingNode,searchFunc
  64.     local sortingEnabled,autoUpdateSearch
  65.     local table,math = table,math
  66.     local nilMap,nilCons = {},{}
  67.     local connectSignal = game["Run Service"].Parent.DescendantAdded.Connect
  68.     local addObject,removeObject,moveObject = nil,nil,nil
  69.  
  70.     addObject = function(root)
  71.         if nodes[root] then return end
  72.  
  73.         local isNil = false
  74.         local rootParObj = ffa(root,"Instance")
  75.         local par = nodes[rootParObj]
  76.  
  77.         -- Nil Handling
  78.         if not par then
  79.             if nilMap[root] then
  80.                 nilCons[root] = nilCons[root] or {
  81.                     connectSignal(root.ChildAdded,addObject),
  82.                     connectSignal(root.AncestryChanged,moveObject),
  83.                 }
  84.                 par = nilNode
  85.                 isNil = true
  86.             else
  87.                 return
  88.             end
  89.         elseif nilMap[rootParObj] or par == nilNode then
  90.             nilMap[root] = true
  91.             nilCons[root] = nilCons[root] or {
  92.                 connectSignal(root.ChildAdded,addObject),
  93.                 connectSignal(root.AncestryChanged,moveObject),
  94.             }
  95.             isNil = true
  96.         end
  97.  
  98.         local newNode = {Obj = root, Parent = par}
  99.         nodes[root] = newNode
  100.  
  101.         -- Automatic sorting if expanded
  102.         if sortingEnabled and expanded[par] and par.Sorted then
  103.             local left,right = 1,#par
  104.             local floor = math.floor
  105.             local sorter = Explorer.NodeSorter
  106.             local pos = (right == 0 and 1)
  107.  
  108.             if not pos then
  109.                 while true do
  110.                     if left >= right then
  111.                         if sorter(newNode,par[left]) then
  112.                             pos = left
  113.                         else
  114.                             pos = left+1
  115.                         end
  116.                         break
  117.                     end
  118.  
  119.                     local mid = floor((left+right)/2)
  120.                     if sorter(newNode,par[mid]) then
  121.                         right = mid-1
  122.                     else
  123.                         left = mid+1
  124.                     end
  125.                 end
  126.             end
  127.  
  128.             table.insert(par,pos,newNode)
  129.         else
  130.             par[#par+1] = newNode
  131.             par.Sorted = nil
  132.         end
  133.  
  134.         local insts = getDescendants(root)
  135.         for i = 1,#insts do
  136.             local obj = insts[i]
  137.             if nodes[obj] then continue end -- Deferred
  138.            
  139.             local par = nodes[ffa(obj,"Instance")]
  140.             if not par then continue end
  141.             local newNode = {Obj = obj, Parent = par}
  142.             nodes[obj] = newNode
  143.             par[#par+1] = newNode
  144.  
  145.             -- Nil Handling
  146.             if isNil then
  147.                 nilMap[obj] = true
  148.                 nilCons[obj] = nilCons[obj] or {
  149.                     connectSignal(obj.ChildAdded,addObject),
  150.                     connectSignal(obj.AncestryChanged,moveObject),
  151.                 }
  152.             end
  153.         end
  154.  
  155.         if searchFunc and autoUpdateSearch then
  156.             searchFunc({newNode})
  157.         end
  158.  
  159.         if not updateDebounce and Explorer.IsNodeVisible(par) then
  160.             if expanded[par] then
  161.                 Explorer.PerformUpdate()
  162.             elseif not refreshDebounce then
  163.                 Explorer.PerformRefresh()
  164.             end
  165.         end
  166.     end
  167.  
  168.     removeObject = function(root)
  169.         local node = nodes[root]
  170.         if not node then return end
  171.  
  172.         -- Nil Handling
  173.         if nilMap[node.Obj] then
  174.             moveObject(node.Obj)
  175.             return
  176.         end
  177.  
  178.         local par = node.Parent
  179.         if par then
  180.             par.HasDel = true
  181.         end
  182.  
  183.         local function recur(root)
  184.             for i = 1,#root do
  185.                 local node = root[i]
  186.                 if not node.Del then
  187.                     nodes[node.Obj] = nil
  188.                     if #node > 0 then recur(node) end
  189.                 end
  190.             end
  191.         end
  192.         recur(node)
  193.         node.Del = true
  194.         nodes[root] = nil
  195.  
  196.         if par and not updateDebounce and Explorer.IsNodeVisible(par) then
  197.             if expanded[par] then
  198.                 Explorer.PerformUpdate()
  199.             elseif not refreshDebounce then
  200.                 Explorer.PerformRefresh()
  201.             end
  202.         end
  203.     end
  204.  
  205.     moveObject = function(obj)
  206.         local node = nodes[obj]
  207.         if not node then return end
  208.  
  209.         local oldPar = node.Parent
  210.         local newPar = nodes[ffa(obj,"Instance")]
  211.         if oldPar == newPar then return end
  212.  
  213.         -- Nil Handling
  214.         if not newPar then
  215.             if nilMap[obj] then
  216.                 newPar = nilNode
  217.             else
  218.                 return
  219.             end
  220.         elseif nilMap[newPar.Obj] or newPar == nilNode then
  221.             nilMap[obj] = true
  222.             nilCons[obj] = nilCons[obj] or {
  223.                 connectSignal(obj.ChildAdded,addObject),
  224.                 connectSignal(obj.AncestryChanged,moveObject),
  225.             }
  226.         end
  227.  
  228.         if oldPar then
  229.             local parPos = table.find(oldPar,node)
  230.             if parPos then table.remove(oldPar,parPos) end
  231.         end
  232.  
  233.         node.Id = nil
  234.         node.Parent = newPar
  235.  
  236.         if sortingEnabled and expanded[newPar] and newPar.Sorted then
  237.             local left,right = 1,#newPar
  238.             local floor = math.floor
  239.             local sorter = Explorer.NodeSorter
  240.             local pos = (right == 0 and 1)
  241.  
  242.             if not pos then
  243.                 while true do
  244.                     if left >= right then
  245.                         if sorter(node,newPar[left]) then
  246.                             pos = left
  247.                         else
  248.                             pos = left+1
  249.                         end
  250.                         break
  251.                     end
  252.  
  253.                     local mid = floor((left+right)/2)
  254.                     if sorter(node,newPar[mid]) then
  255.                         right = mid-1
  256.                     else
  257.                         left = mid+1
  258.                     end
  259.                 end
  260.             end
  261.  
  262.             table.insert(newPar,pos,node)
  263.         else
  264.             newPar[#newPar+1] = node
  265.             newPar.Sorted = nil
  266.         end
  267.  
  268.         if searchFunc and searchResults[node] then
  269.             local currentNode = node.Parent
  270.             while currentNode and (not searchResults[currentNode] or expanded[currentNode] == 0) do
  271.                 expanded[currentNode] = true
  272.                 searchResults[currentNode] = true
  273.                 currentNode = currentNode.Parent
  274.             end
  275.         end
  276.  
  277.         if not updateDebounce and (Explorer.IsNodeVisible(newPar) or Explorer.IsNodeVisible(oldPar)) then
  278.             if expanded[newPar] or expanded[oldPar] then
  279.                 Explorer.PerformUpdate()
  280.             elseif not refreshDebounce then
  281.                 Explorer.PerformRefresh()
  282.             end
  283.         end
  284.     end
  285.  
  286.     Explorer.ViewWidth = 0
  287.     Explorer.Index = 0
  288.     Explorer.EntryIndent = 20
  289.     Explorer.FreeWidth = 32
  290.     Explorer.GuiElems = {}
  291.  
  292.     Explorer.InitRenameBox = function()
  293.         renameBox = create({{1,"TextBox",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.062745101749897,0.51764708757401,1),BorderMode=2,ClearTextOnFocus=false,Font=3,Name="RenameBox",PlaceholderColor3=Color3.new(0.69803923368454,0.69803923368454,0.69803923368454),Position=UDim2.new(0,26,0,2),Size=UDim2.new(0,200,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,Visible=false,ZIndex=2}}})
  294.  
  295.         renameBox.Parent = Explorer.Window.GuiElems.Content.List
  296.  
  297.         renameBox.FocusLost:Connect(function()
  298.             if not renamingNode then return end
  299.  
  300.             pcall(function() renamingNode.Obj.Name = renameBox.Text end)
  301.             renamingNode = nil
  302.             Explorer.Refresh()
  303.         end)
  304.  
  305.         renameBox.Focused:Connect(function()
  306.             renameBox.SelectionStart = 1
  307.             renameBox.CursorPosition = #renameBox.Text + 1
  308.         end)
  309.     end
  310.  
  311.     Explorer.SetRenamingNode = function(node)
  312.         renamingNode = node
  313.         renameBox.Text = tostring(node.Obj)
  314.         renameBox:CaptureFocus()
  315.         Explorer.Refresh()
  316.     end
  317.  
  318.     Explorer.SetSortingEnabled = function(val)
  319.         sortingEnabled = val
  320.         Settings.Explorer.Sorting = val
  321.     end
  322.  
  323.     Explorer.UpdateView = function()
  324.         local maxNodes = math.ceil(treeFrame.AbsoluteSize.Y / 20)
  325.         local maxX = treeFrame.AbsoluteSize.X
  326.         local totalWidth = Explorer.ViewWidth + Explorer.FreeWidth
  327.  
  328.         scrollV.VisibleSpace = maxNodes
  329.         scrollV.TotalSpace = #tree + 1
  330.         scrollH.VisibleSpace = maxX
  331.         scrollH.TotalSpace = totalWidth
  332.  
  333.         scrollV.Gui.Visible = #tree + 1 > maxNodes
  334.         scrollH.Gui.Visible = totalWidth > maxX
  335.  
  336.         local oldSize = treeFrame.Size
  337.         treeFrame.Size = UDim2.new(1,(scrollV.Gui.Visible and -16 or 0),1,(scrollH.Gui.Visible and -39 or -23))
  338.         if oldSize ~= treeFrame.Size then
  339.             Explorer.UpdateView()
  340.         else
  341.             scrollV:Update()
  342.             scrollH:Update()
  343.  
  344.             renameBox.Size = UDim2.new(0,maxX-100,0,16)
  345.  
  346.             if scrollV.Gui.Visible and scrollH.Gui.Visible then
  347.                 scrollV.Gui.Size = UDim2.new(0,16,1,-39)
  348.                 scrollH.Gui.Size = UDim2.new(1,-16,0,16)
  349.                 Explorer.Window.GuiElems.Content.ScrollCorner.Visible = true
  350.             else
  351.                 scrollV.Gui.Size = UDim2.new(0,16,1,-23)
  352.                 scrollH.Gui.Size = UDim2.new(1,0,0,16)
  353.                 Explorer.Window.GuiElems.Content.ScrollCorner.Visible = false
  354.             end
  355.  
  356.             Explorer.Index = scrollV.Index
  357.         end
  358.     end
  359.  
  360.     Explorer.NodeSorter = function(a,b)
  361.         if a.Del or b.Del then return false end -- Ghost node
  362.  
  363.         local aClass = a.Class
  364.         local bClass = b.Class
  365.         if not aClass then aClass = a.Obj.ClassName a.Class = aClass end
  366.         if not bClass then bClass = b.Obj.ClassName b.Class = bClass end
  367.  
  368.         local aOrder = explorerOrders[aClass]
  369.         local bOrder = explorerOrders[bClass]
  370.         if not aOrder then aOrder = RMD.Classes[aClass] and tonumber(RMD.Classes[aClass].ExplorerOrder) or 9999 explorerOrders[aClass] = aOrder end
  371.         if not bOrder then bOrder = RMD.Classes[bClass] and tonumber(RMD.Classes[bClass].ExplorerOrder) or 9999 explorerOrders[bClass] = bOrder end
  372.  
  373.         if aOrder ~= bOrder then
  374.             return aOrder < bOrder
  375.         else
  376.             local aName,bName = tostring(a.Obj),tostring(b.Obj)
  377.             if aName ~= bName then
  378.                 return aName < bName
  379.             elseif aClass ~= bClass then
  380.                 return aClass < bClass
  381.             else
  382.                 local aId = a.Id if not aId then aId = idCounter idCounter = (idCounter+0.001)%999999999 a.Id = aId end
  383.                 local bId = b.Id if not bId then bId = idCounter idCounter = (idCounter+0.001)%999999999 b.Id = bId end
  384.                 return aId < bId
  385.             end
  386.         end
  387.     end
  388.  
  389.     Explorer.Update = function()
  390.         table.clear(tree)
  391.         local maxNameWidth,maxDepth,count = 0,1,1
  392.         local nameCache = {}
  393.         local font = Enum.Font.SourceSans
  394.         local size = Vector2.new(math.huge,20)
  395.         local useNameWidth = Settings.Explorer.UseNameWidth
  396.         local tSort = table.sort
  397.         local sortFunc = Explorer.NodeSorter
  398.         local isSearching = (expanded == Explorer.SearchExpanded)
  399.         local textServ = service.TextService
  400.  
  401.         local function recur(root,depth)
  402.             if depth > maxDepth then maxDepth = depth end
  403.             depth = depth + 1
  404.             if sortingEnabled and not root.Sorted then
  405.                 tSort(root,sortFunc)
  406.                 root.Sorted = true
  407.             end
  408.             for i = 1,#root do
  409.                 local n = root[i]
  410.  
  411.                 if (isSearching and not searchResults[n]) or n.Del then continue end
  412.  
  413.                 if useNameWidth then
  414.                     local nameWidth = n.NameWidth
  415.                     if not nameWidth then
  416.                         local objName = tostring(n.Obj)
  417.                         nameWidth = nameCache[objName]
  418.                         if not nameWidth then
  419.                             nameWidth = getTextSize(textServ,objName,14,font,size).X
  420.                             nameCache[objName] = nameWidth
  421.                         end
  422.                         n.NameWidth = nameWidth
  423.                     end
  424.                     if nameWidth > maxNameWidth then
  425.                         maxNameWidth = nameWidth
  426.                     end
  427.                 end
  428.  
  429.                 tree[count] = n
  430.                 count = count + 1
  431.                 if expanded[n] and #n > 0 then
  432.                     recur(n,depth)
  433.                 end
  434.             end
  435.         end
  436.  
  437.         recur(nodes[game["Run Service"].Parent],1)
  438.  
  439.         -- Nil Instances
  440.         if env.getnilinstances then
  441.             if not (isSearching and not searchResults[nilNode]) then
  442.                 tree[count] = nilNode
  443.                 count = count + 1
  444.                 if expanded[nilNode] then
  445.                     recur(nilNode,2)
  446.                 end
  447.             end
  448.         end
  449.  
  450.         Explorer.MaxNameWidth = maxNameWidth
  451.         Explorer.MaxDepth = maxDepth
  452.         Explorer.ViewWidth = useNameWidth and Explorer.EntryIndent*maxDepth + maxNameWidth + 26 or Explorer.EntryIndent*maxDepth + 226
  453.         Explorer.UpdateView()
  454.     end
  455.  
  456.     Explorer.StartDrag = function(offX,offY)
  457.         if Explorer.Dragging then return end
  458.         Explorer.Dragging = true
  459.  
  460.         local dragTree = treeFrame:Clone()
  461.         dragTree:ClearAllChildren()
  462.  
  463.         for i,v in pairs(listEntries) do
  464.             local node = tree[i + Explorer.Index]
  465.             if node and selection.Map[node] then
  466.                 local clone = v:Clone()
  467.                 clone.Active = false
  468.                 clone.Indent.Expand.Visible = false
  469.                 clone.Parent = dragTree
  470.             end
  471.         end
  472.  
  473.         local newGui = Instance.new("ScreenGui")
  474.         newGui.DisplayOrder = Main.DisplayOrders.Menu
  475.         dragTree.Parent = newGui
  476.         Lib.ShowGui(newGui)
  477.  
  478.         local dragOutline = create({
  479.             {1,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="DragSelect",Size=UDim2.new(1,0,1,0),}},
  480.             {2,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Size=UDim2.new(1,0,0,1),ZIndex=2,}},
  481.             {3,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Position=UDim2.new(0,0,1,-1),Size=UDim2.new(1,0,0,1),ZIndex=2,}},
  482.             {4,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Size=UDim2.new(0,1,1,0),ZIndex=2,}},
  483.             {5,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Line",Parent={1},Position=UDim2.new(1,-1,0,0),Size=UDim2.new(0,1,1,0),ZIndex=2,}},
  484.         })
  485.         dragOutline.Parent = treeFrame
  486.  
  487.  
  488.         local mouse = Main.Mouse or service.Players.LocalPlayer:GetMouse()
  489.         local function move()
  490.             local posX = mouse.X - offX
  491.             local posY = mouse.Y - offY
  492.             dragTree.Position = UDim2.new(0,posX,0,posY)
  493.  
  494.             for i = 1,#listEntries do
  495.                 local entry = listEntries[i]
  496.                 if Lib.CheckMouseInGui(entry) then
  497.                     dragOutline.Position = UDim2.new(0,entry.Indent.Position.X.Offset-scrollH.Index,0,entry.Position.Y.Offset)
  498.                     dragOutline.Size = UDim2.new(0,entry.Size.X.Offset-entry.Indent.Position.X.Offset,0,20)
  499.                     dragOutline.Visible = true
  500.                     return
  501.                 end
  502.             end
  503.             dragOutline.Visible = false
  504.         end
  505.         move()
  506.  
  507.         local input = service.UserInputService
  508.         local mouseEvent,releaseEvent
  509.  
  510.         mouseEvent = input.InputChanged:Connect(function(input)
  511.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  512.                 move()
  513.             end
  514.         end)
  515.  
  516.         releaseEvent = input.InputEnded:Connect(function(input)
  517.             if input.UserInputType == Enum.UserInputType.MouseButton1 then
  518.                 releaseEvent:Disconnect()
  519.                 mouseEvent:Disconnect()
  520.                 newGui:Destroy()
  521.                 dragOutline:Destroy()
  522.                 Explorer.Dragging = false
  523.  
  524.                 for i = 1,#listEntries do
  525.                     if Lib.CheckMouseInGui(listEntries[i]) then
  526.                         local node = tree[i + Explorer.Index]
  527.                         if node then
  528.                             if selection.Map[node] then return end
  529.                             local newPar = node.Obj
  530.                             local sList = selection.List
  531.                             for i = 1,#sList do
  532.                                 local n = sList[i]
  533.                                 pcall(function() n.Obj.Parent = newPar end)
  534.                             end
  535.                             Explorer.ViewNode(sList[1])
  536.                         end
  537.                         break
  538.                     end
  539.                 end
  540.             end
  541.         end)
  542.     end
  543.  
  544.     Explorer.NewListEntry = function(index)
  545.         local newEntry = entryTemplate:Clone()
  546.         newEntry.Position = UDim2.new(0,0,0,20*(index-1))
  547.  
  548.         local isRenaming = false
  549.  
  550.         newEntry.InputBegan:Connect(function(input)
  551.             local node = tree[index + Explorer.Index]
  552.             if not node or selection.Map[node] or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  553.  
  554.             newEntry.Indent.BackgroundColor3 = Settings.Theme.Button
  555.             newEntry.Indent.BorderSizePixel = 0
  556.             newEntry.Indent.BackgroundTransparency = 0
  557.         end)
  558.  
  559.         newEntry.InputEnded:Connect(function(input)
  560.             local node = tree[index + Explorer.Index]
  561.             if not node or selection.Map[node] or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  562.  
  563.             newEntry.Indent.BackgroundTransparency = 1
  564.         end)
  565.  
  566.         newEntry.MouseButton1Down:Connect(function()
  567.  
  568.         end)
  569.  
  570.         newEntry.MouseButton1Up:Connect(function()
  571.  
  572.         end)
  573.  
  574.         newEntry.InputBegan:Connect(function(input)
  575.             if input.UserInputType == Enum.UserInputType.MouseButton1 then
  576.                 local releaseEvent,mouseEvent
  577.  
  578.                 local mouse = Main.Mouse or plr:GetMouse()
  579.                 local startX = mouse.X
  580.                 local startY = mouse.Y
  581.  
  582.                 local listOffsetX = startX - treeFrame.AbsolutePosition.X
  583.                 local listOffsetY = startY - treeFrame.AbsolutePosition.Y
  584.  
  585.                 releaseEvent = cloneref(game["Run Service"].Parent:GetService("UserInputService")).InputEnded:Connect(function(input)
  586.                     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  587.                         releaseEvent:Disconnect()
  588.                         mouseEvent:Disconnect()
  589.                     end
  590.                 end)
  591.  
  592.                 mouseEvent = cloneref(game["Run Service"].Parent:GetService("UserInputService")).InputChanged:Connect(function(input)
  593.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  594.                         local deltaX = mouse.X - startX
  595.                         local deltaY = mouse.Y - startY
  596.                         local dist = math.sqrt(deltaX^2 + deltaY^2)
  597.  
  598.                         if dist > 5 then
  599.                             releaseEvent:Disconnect()
  600.                             mouseEvent:Disconnect()
  601.                             isRenaming = false
  602.                             Explorer.StartDrag(listOffsetX,listOffsetY)
  603.                         end
  604.                     end
  605.                 end)
  606.             end
  607.         end)
  608.  
  609.         newEntry.MouseButton2Down:Connect(function()
  610.  
  611.         end)
  612.  
  613.         newEntry.Indent.Expand.InputBegan:Connect(function(input)
  614.             local node = tree[index + Explorer.Index]
  615.             if not node or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  616.  
  617.             Explorer.MiscIcons:DisplayByKey(newEntry.Indent.Expand.Icon, expanded[node] and "Collapse_Over" or "Expand_Over")
  618.         end)
  619.  
  620.         newEntry.Indent.Expand.InputEnded:Connect(function(input)
  621.             local node = tree[index + Explorer.Index]
  622.             if not node or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  623.  
  624.             Explorer.MiscIcons:DisplayByKey(newEntry.Indent.Expand.Icon, expanded[node] and "Collapse" or "Expand")
  625.         end)
  626.  
  627.         newEntry.Indent.Expand.MouseButton1Down:Connect(function()
  628.             local node = tree[index + Explorer.Index]
  629.             if not node or #node == 0 then return end
  630.  
  631.             expanded[node] = not expanded[node]
  632.             Explorer.Update()
  633.             Explorer.Refresh()
  634.         end)
  635.  
  636.         newEntry.Parent = treeFrame
  637.         return newEntry
  638.     end
  639.  
  640.     Explorer.Refresh = function()
  641.         local maxNodes = math.max(math.ceil((treeFrame.AbsoluteSize.Y) / 20),0)
  642.         local renameNodeVisible = false
  643.         local isa = game["Run Service"].Parent.IsA
  644.  
  645.         for i = 1,maxNodes do
  646.             local entry = listEntries[i]
  647.             if not listEntries[i] then entry = Explorer.NewListEntry(i) listEntries[i] = entry Explorer.ClickSystem:Add(entry) end
  648.  
  649.             local node = tree[i + Explorer.Index]
  650.             if node then
  651.                 local obj = node.Obj
  652.                 local depth = Explorer.EntryIndent*Explorer.NodeDepth(node)
  653.  
  654.                 entry.Visible = true
  655.                 entry.Position = UDim2.new(0,-scrollH.Index,0,entry.Position.Y.Offset)
  656.                 entry.Size = UDim2.new(0,Explorer.ViewWidth,0,20)
  657.                 entry.Indent.EntryName.Text = tostring(node.Obj)
  658.                 entry.Indent.Position = UDim2.new(0,depth,0,0)
  659.                 entry.Indent.Size = UDim2.new(1,-depth,1,0)
  660.  
  661.                 entry.Indent.EntryName.TextTruncate = (Settings.Explorer.UseNameWidth and Enum.TextTruncate.None or Enum.TextTruncate.AtEnd)
  662.  
  663.                 if (isa(obj,"LocalScript") or isa(obj,"Script")) and obj.Disabled then
  664.                     Explorer.MiscIcons:DisplayByKey(entry.Indent.Icon, isa(obj,"LocalScript") and "LocalScript_Disabled" or "Script_Disabled")
  665.                 else
  666.                     local rmdEntry = RMD.Classes[obj.ClassName]
  667.                     Explorer.ClassIcons:Display(entry.Indent.Icon, rmdEntry and rmdEntry.ExplorerImageIndex or 0)
  668.                 end
  669.  
  670.                 if selection.Map[node] then
  671.                     entry.Indent.BackgroundColor3 = Settings.Theme.ListSelection
  672.                     entry.Indent.BorderSizePixel = 0
  673.                     entry.Indent.BackgroundTransparency = 0
  674.                 else
  675.                     if Lib.CheckMouseInGui(entry) then
  676.                         entry.Indent.BackgroundColor3 = Settings.Theme.Button
  677.                     else
  678.                         entry.Indent.BackgroundTransparency = 1
  679.                     end
  680.                 end
  681.  
  682.                 if node == renamingNode then
  683.                     renameNodeVisible = true
  684.                     renameBox.Position = UDim2.new(0,depth+25-scrollH.Index,0,entry.Position.Y.Offset+2)
  685.                     renameBox.Visible = true
  686.                 end
  687.  
  688.                 if #node > 0 and expanded[node] ~= 0 then
  689.                     if Lib.CheckMouseInGui(entry.Indent.Expand) then
  690.                         Explorer.MiscIcons:DisplayByKey(entry.Indent.Expand.Icon, expanded[node] and "Collapse_Over" or "Expand_Over")
  691.                     else
  692.                         Explorer.MiscIcons:DisplayByKey(entry.Indent.Expand.Icon, expanded[node] and "Collapse" or "Expand")
  693.                     end
  694.                     entry.Indent.Expand.Visible = true
  695.                 else
  696.                     entry.Indent.Expand.Visible = false
  697.                 end
  698.             else
  699.                 entry.Visible = false
  700.             end
  701.         end
  702.  
  703.         if not renameNodeVisible then
  704.             renameBox.Visible = false
  705.         end
  706.  
  707.         for i = maxNodes+1, #listEntries do
  708.             Explorer.ClickSystem:Remove(listEntries[i])
  709.             listEntries[i]:Destroy()
  710.             listEntries[i] = nil
  711.         end
  712.     end
  713.  
  714.     Explorer.PerformUpdate = function(instant)
  715.         updateDebounce = true
  716.         Lib.FastWait(not instant and 0.1)
  717.         if not updateDebounce then return end
  718.         updateDebounce = false
  719.         if not Explorer.Window:IsVisible() then return end
  720.         Explorer.Update()
  721.         Explorer.Refresh()
  722.     end
  723.  
  724.     Explorer.ForceUpdate = function(norefresh)
  725.         updateDebounce = false
  726.         Explorer.Update()
  727.         if not norefresh then Explorer.Refresh() end
  728.     end
  729.  
  730.     Explorer.PerformRefresh = function()
  731.         refreshDebounce = true
  732.         Lib.FastWait(0.1)
  733.         refreshDebounce = false
  734.         if updateDebounce or not Explorer.Window:IsVisible() then return end
  735.         Explorer.Refresh()
  736.     end
  737.  
  738.     Explorer.IsNodeVisible = function(node)
  739.         if not node then return end
  740.  
  741.         local curNode = node.Parent
  742.         while curNode do
  743.             if not expanded[curNode] then return false end
  744.             curNode = curNode.Parent
  745.         end
  746.         return true
  747.     end
  748.  
  749.     Explorer.NodeDepth = function(node)
  750.         local depth = 0
  751.  
  752.         if node == nilNode then
  753.             return 1
  754.         end
  755.  
  756.         local curNode = node.Parent
  757.         while curNode do
  758.             if curNode == nilNode then depth = depth + 1 end
  759.             curNode = curNode.Parent
  760.             depth = depth + 1
  761.         end
  762.         return depth
  763.     end
  764.  
  765.     Explorer.SetupConnections = function()
  766.         if descendantAddedCon then descendantAddedCon:Disconnect() end
  767.         if descendantRemovingCon then descendantRemovingCon:Disconnect() end
  768.         if itemChangedCon then itemChangedCon:Disconnect() end
  769.  
  770.         if Main.Elevated then
  771.             descendantAddedCon = game["Run Service"].Parent.DescendantAdded:Connect(addObject)
  772.             descendantRemovingCon = game["Run Service"].Parent.DescendantRemoving:Connect(removeObject)
  773.         else
  774.             descendantAddedCon = game["Run Service"].Parent.DescendantAdded:Connect(function(obj) pcall(addObject,obj) end)
  775.             descendantRemovingCon = game["Run Service"].Parent.DescendantRemoving:Connect(function(obj) pcall(removeObject,obj) end)
  776.         end
  777.  
  778.         if Settings.Explorer.UseNameWidth then
  779.             itemChangedCon = game["Run Service"].Parent.ItemChanged:Connect(function(obj,prop)
  780.                 if prop == "Parent" and nodes[obj] then
  781.                     moveObject(obj)
  782.                 elseif prop == "Name" and nodes[obj] then
  783.                     nodes[obj].NameWidth = nil
  784.                 end
  785.             end)
  786.         else
  787.             itemChangedCon = game["Run Service"].Parent.ItemChanged:Connect(function(obj,prop)
  788.                 if prop == "Parent" and nodes[obj] then
  789.                     moveObject(obj)
  790.                 end
  791.             end)
  792.         end
  793.     end
  794.  
  795.     Explorer.ViewNode = function(node)
  796.         if not node then return end
  797.  
  798.         Explorer.MakeNodeVisible(node)
  799.         Explorer.ForceUpdate(true)
  800.         local visibleSpace = scrollV.VisibleSpace
  801.  
  802.         for i,v in next,tree do
  803.             if v == node then
  804.                 local relative = i - 1
  805.                 if Explorer.Index > relative then
  806.                     scrollV.Index = relative
  807.                 elseif Explorer.Index + visibleSpace - 1 <= relative then
  808.                     scrollV.Index = relative - visibleSpace + 2
  809.                 end
  810.             end
  811.         end
  812.  
  813.         scrollV:Update() Explorer.Index = scrollV.Index
  814.         Explorer.Refresh()
  815.     end
  816.  
  817.     Explorer.ViewObj = function(obj)
  818.         Explorer.ViewNode(nodes[obj])
  819.     end
  820.  
  821.     Explorer.MakeNodeVisible = function(node,expandRoot)
  822.         if not node then return end
  823.  
  824.         local hasExpanded = false
  825.  
  826.         if expandRoot and not expanded[node] then
  827.             expanded[node] = true
  828.             hasExpanded = true
  829.         end
  830.  
  831.         local currentNode = node.Parent
  832.         while currentNode do
  833.             hasExpanded = true
  834.             expanded[currentNode] = true
  835.             currentNode = currentNode.Parent
  836.         end
  837.  
  838.         if hasExpanded and not updateDebounce then
  839.             coroutine.wrap(Explorer.PerformUpdate)(true)
  840.         end
  841.     end
  842.  
  843.     Explorer.ShowRightClick = function()
  844.         local context = Explorer.RightClickContext
  845.         context:Clear()
  846.  
  847.         local sList = selection.List
  848.         local sMap = selection.Map
  849.         local emptyClipboard = #clipboard == 0
  850.         local presentClasses = {}
  851.         local apiClasses = API.Classes
  852.  
  853.         for i = 1, #sList do
  854.             local node = sList[i]
  855.             local class = node.Class
  856.             if not class then class = node.Obj.ClassName node.Class = class end
  857.             local curClass = apiClasses[class]
  858.             while curClass and not presentClasses[curClass.Name] do
  859.                 presentClasses[curClass.Name] = true
  860.                 curClass = curClass.Superclass
  861.             end
  862.         end
  863.  
  864.         context:AddRegistered("CUT")
  865.         context:AddRegistered("COPY")
  866.         context:AddRegistered("PASTE", emptyClipboard)
  867.         context:AddRegistered("DUPLICATE")
  868.         context:AddRegistered("DELETE")
  869.         context:AddRegistered("RENAME", #sList ~= 1)
  870.  
  871.         context:AddDivider()
  872.         context:AddRegistered("GROUP")
  873.         context:AddRegistered("UNGROUP")
  874.         context:AddRegistered("SELECT_CHILDREN")
  875.         context:AddRegistered("JUMP_TO_PARENT")
  876.         context:AddRegistered("EXPAND_ALL")
  877.         context:AddRegistered("COLLAPSE_ALL")
  878.  
  879.         context:AddDivider()
  880.         if expanded == Explorer.SearchExpanded then context:AddRegistered("CLEAR_SEARCH_AND_JUMP_TO") end
  881.         if env.setclipboard then context:AddRegistered("COPY_PATH") end
  882.         context:AddRegistered("INSERT_OBJECT")
  883.         context:AddRegistered("SAVE_INST")
  884.         context:AddRegistered("CALL_FUNCTION")
  885.         context:AddRegistered("VIEW_CONNECTIONS")
  886.         context:AddRegistered("GET_REFERENCES")
  887.         context:AddRegistered("VIEW_API")
  888.        
  889.         context:QueueDivider()
  890.  
  891.         if presentClasses["BasePart"] or presentClasses["Model"] then
  892.             context:AddRegistered("TELEPORT_TO")
  893.             context:AddRegistered("VIEW_OBJECT")
  894.         end
  895.  
  896.         if presentClasses["TouchTransmitter"] then context:AddRegistered("FIRE_TOUCHTRANSMITTER", firetouchinterest == nil) end
  897.         if presentClasses["ClickDetector"] then context:AddRegistered("FIRE_CLICKDETECTOR", fireclickdetector == nil) end
  898.         if presentClasses["ProximityPrompt"] then context:AddRegistered("FIRE_PROXIMITYPROMPT", fireproximityprompt == nil) end
  899.         if presentClasses["Player"] then context:AddRegistered("SELECT_CHARACTER") end
  900.         if presentClasses["Players"] then context:AddRegistered("SELECT_LOCAL_PLAYER") end
  901.         if presentClasses["LuaSourceContainer"] then context:AddRegistered("VIEW_SCRIPT") end
  902.  
  903.         if sMap[nilNode] then
  904.             context:AddRegistered("REFRESH_NIL")
  905.             context:AddRegistered("HIDE_NIL")
  906.         end
  907.  
  908.         Explorer.LastRightClickX, Explorer.LastRightClickY = Main.Mouse.X, Main.Mouse.Y
  909.         context:Show()
  910.     end
  911.  
  912.     Explorer.InitRightClick = function()
  913.         local context = Lib.ContextMenu.new()
  914.  
  915.         context:Register("CUT",{Name = "Cut", IconMap = Explorer.MiscIcons, Icon = "Cut", DisabledIcon = "Cut_Disabled", Shortcut = "Ctrl+Z", OnClick = function()
  916.             local destroy,clone = game["Run Service"].Parent.Destroy,game["Run Service"].Parent.Clone
  917.             local sList,newClipboard = selection.List,{}
  918.             local count = 1
  919.             for i = 1,#sList do
  920.                 local inst = sList[i].Obj
  921.                 local s,cloned = pcall(clone,inst)
  922.                 if s and cloned then
  923.                     newClipboard[count] = cloned
  924.                     count = count + 1
  925.                 end
  926.                 pcall(destroy,inst)
  927.             end
  928.             clipboard = newClipboard
  929.             selection:Clear()
  930.         end})
  931.  
  932.         context:Register("COPY",{Name = "Copy", IconMap = Explorer.MiscIcons, Icon = "Copy", DisabledIcon = "Copy_Disabled", Shortcut = "Ctrl+C", OnClick = function()
  933.             local clone = game["Run Service"].Parent.Clone
  934.             local sList,newClipboard = selection.List,{}
  935.             local count = 1
  936.             for i = 1,#sList do
  937.                 local inst = sList[i].Obj
  938.                 local s,cloned = pcall(clone,inst)
  939.                 if s and cloned then
  940.                     newClipboard[count] = cloned
  941.                     count = count + 1
  942.                 end
  943.             end
  944.             clipboard = newClipboard
  945.         end})
  946.  
  947.         context:Register("PASTE",{Name = "Paste Into", IconMap = Explorer.MiscIcons, Icon = "Paste", DisabledIcon = "Paste_Disabled", Shortcut = "Ctrl+Shift+V", OnClick = function()
  948.             local sList = selection.List
  949.             local newSelection = {}
  950.             local count = 1
  951.             for i = 1,#sList do
  952.                 local node = sList[i]
  953.                 local inst = node.Obj
  954.                 Explorer.MakeNodeVisible(node,true)
  955.                 for c = 1,#clipboard do
  956.                     local cloned = clipboard[c]:Clone()
  957.                     if cloned then
  958.                         cloned.Parent = inst
  959.                         local clonedNode = nodes[cloned]
  960.                         if clonedNode then newSelection[count] = clonedNode count = count + 1 end
  961.                     end
  962.                 end
  963.             end
  964.             selection:SetTable(newSelection)
  965.  
  966.             if #newSelection > 0 then
  967.                 Explorer.ViewNode(newSelection[1])
  968.             end
  969.         end})
  970.  
  971.         context:Register("DUPLICATE",{Name = "Duplicate", IconMap = Explorer.MiscIcons, Icon = "Copy", DisabledIcon = "Copy_Disabled", Shortcut = "Ctrl+D", OnClick = function()
  972.             local clone = game["Run Service"].Parent.Clone
  973.             local sList = selection.List
  974.             local newSelection = {}
  975.             local count = 1
  976.             for i = 1,#sList do
  977.                 local node = sList[i]
  978.                 local inst = node.Obj
  979.                 local instPar = node.Parent and node.Parent.Obj
  980.                 Explorer.MakeNodeVisible(node)
  981.                 local s,cloned = pcall(clone,inst)
  982.                 if s and cloned then
  983.                     cloned.Parent = instPar
  984.                     local clonedNode = nodes[cloned]
  985.                     if clonedNode then newSelection[count] = clonedNode count = count + 1 end
  986.                 end
  987.             end
  988.  
  989.             selection:SetTable(newSelection)
  990.             if #newSelection > 0 then
  991.                 Explorer.ViewNode(newSelection[1])
  992.             end
  993.         end})
  994.  
  995.         context:Register("DELETE",{Name = "Delete", IconMap = Explorer.MiscIcons, Icon = "Delete", DisabledIcon = "Delete_Disabled", Shortcut = "Del", OnClick = function()
  996.             local destroy = game["Run Service"].Parent.Destroy
  997.             local sList = selection.List
  998.             for i = 1,#sList do
  999.                 pcall(destroy,sList[i].Obj)
  1000.             end
  1001.             selection:Clear()
  1002.         end})
  1003.  
  1004.         context:Register("RENAME",{Name = "Rename", IconMap = Explorer.MiscIcons, Icon = "Rename", DisabledIcon = "Rename_Disabled", Shortcut = "F2", OnClick = function()
  1005.             local sList = selection.List
  1006.             if sList[1] then
  1007.                 Explorer.SetRenamingNode(sList[1])
  1008.             end
  1009.         end})
  1010.  
  1011.         context:Register("GROUP",{Name = "Group", IconMap = Explorer.MiscIcons, Icon = "Group", DisabledIcon = "Group_Disabled", Shortcut = "Ctrl+G", OnClick = function()
  1012.             local sList = selection.List
  1013.             if #sList == 0 then return end
  1014.  
  1015.             local model = Instance.new("Model",sList[#sList].Obj.Parent)
  1016.             for i = 1,#sList do
  1017.                 pcall(function() sList[i].Obj.Parent = model end)
  1018.             end
  1019.  
  1020.             if nodes[model] then
  1021.                 selection:Set(nodes[model])
  1022.                 Explorer.ViewNode(nodes[model])
  1023.             end
  1024.         end})
  1025.  
  1026.         context:Register("UNGROUP",{Name = "Ungroup", IconMap = Explorer.MiscIcons, Icon = "Ungroup", DisabledIcon = "Ungroup_Disabled", Shortcut = "Ctrl+U", OnClick = function()
  1027.             local newSelection = {}
  1028.             local count = 1
  1029.             local isa = game["Run Service"].Parent.IsA
  1030.  
  1031.             local function ungroup(node)
  1032.                 local par = node.Parent.Obj
  1033.                 local ch = {}
  1034.                 local chCount = 1
  1035.  
  1036.                 for i = 1,#node do
  1037.                     local n = node[i]
  1038.                     newSelection[count] = n
  1039.                     ch[chCount] = n
  1040.                     count = count + 1
  1041.                     chCount = chCount + 1
  1042.                 end
  1043.  
  1044.                 for i = 1,#ch do
  1045.                     pcall(function() ch[i].Obj.Parent = par end)
  1046.                 end
  1047.  
  1048.                 node.Obj:Destroy()
  1049.             end
  1050.  
  1051.             for i,v in next,selection.List do
  1052.                 if isa(v.Obj,"Model") then
  1053.                     ungroup(v)
  1054.                 end
  1055.             end
  1056.  
  1057.             selection:SetTable(newSelection)
  1058.             if #newSelection > 0 then
  1059.                 Explorer.ViewNode(newSelection[1])
  1060.             end
  1061.         end})
  1062.  
  1063.         context:Register("SELECT_CHILDREN",{Name = "Select Children", IconMap = Explorer.MiscIcons, Icon = "SelectChildren", DisabledIcon = "SelectChildren_Disabled", OnClick = function()
  1064.             local newSelection = {}
  1065.             local count = 1
  1066.             local sList = selection.List
  1067.  
  1068.             for i = 1,#sList do
  1069.                 local node = sList[i]
  1070.                 for ind = 1,#node do
  1071.                     local cNode = node[ind]
  1072.                     if ind == 1 then Explorer.MakeNodeVisible(cNode) end
  1073.  
  1074.                     newSelection[count] = cNode
  1075.                     count = count + 1
  1076.                 end
  1077.             end
  1078.  
  1079.             selection:SetTable(newSelection)
  1080.             if #newSelection > 0 then
  1081.                 Explorer.ViewNode(newSelection[1])
  1082.             else
  1083.                 Explorer.Refresh()
  1084.             end
  1085.         end})
  1086.  
  1087.         context:Register("JUMP_TO_PARENT",{Name = "Jump to Parent", IconMap = Explorer.MiscIcons, Icon = "JumpToParent", OnClick = function()
  1088.             local newSelection = {}
  1089.             local count = 1
  1090.             local sList = selection.List
  1091.  
  1092.             for i = 1,#sList do
  1093.                 local node = sList[i]
  1094.                 if node.Parent then
  1095.                     newSelection[count] = node.Parent
  1096.                     count = count + 1
  1097.                 end
  1098.             end
  1099.  
  1100.             selection:SetTable(newSelection)
  1101.             if #newSelection > 0 then
  1102.                 Explorer.ViewNode(newSelection[1])
  1103.             else
  1104.                 Explorer.Refresh()
  1105.             end
  1106.         end})
  1107.  
  1108.         context:Register("TELEPORT_TO",{Name = "Teleport To", IconMap = Explorer.MiscIcons, Icon = "TeleportTo", OnClick = function()
  1109.             local sList = selection.List
  1110.             local isa = game["Run Service"].Parent.IsA
  1111.  
  1112.             local hrp = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
  1113.             if not hrp then return end
  1114.  
  1115.             for i = 1,#sList do
  1116.                 local node = sList[i]
  1117.  
  1118.                 if isa(node.Obj,"BasePart") then
  1119.                     hrp.CFrame = node.Obj.CFrame + Settings.Explorer.TeleportToOffset
  1120.                     break
  1121.                 elseif isa(node.Obj,"Model") then
  1122.                     if node.Obj.PrimaryPart then
  1123.                         hrp.CFrame = node.Obj.PrimaryPart.CFrame + Settings.Explorer.TeleportToOffset
  1124.                         break
  1125.                     else
  1126.                         local part = node.Obj:FindFirstChildWhichIsA("BasePart",true)
  1127.                         if part and nodes[part] then
  1128.                             hrp.CFrame = nodes[part].Obj.CFrame + Settings.Explorer.TeleportToOffset
  1129.                         end
  1130.                     end
  1131.                 end
  1132.             end
  1133.         end})
  1134.  
  1135.         context:Register("EXPAND_ALL",{Name = "Expand All", OnClick = function()
  1136.             local sList = selection.List
  1137.  
  1138.             local function expand(node)
  1139.                 expanded[node] = true
  1140.                 for i = 1,#node do
  1141.                     if #node[i] > 0 then
  1142.                         expand(node[i])
  1143.                     end
  1144.                 end
  1145.             end
  1146.  
  1147.             for i = 1,#sList do
  1148.                 expand(sList[i])
  1149.             end
  1150.  
  1151.             Explorer.ForceUpdate()
  1152.         end})
  1153.  
  1154.         context:Register("COLLAPSE_ALL",{Name = "Collapse All", OnClick = function()
  1155.             local sList = selection.List
  1156.  
  1157.             local function expand(node)
  1158.                 expanded[node] = nil
  1159.                 for i = 1,#node do
  1160.                     if #node[i] > 0 then
  1161.                         expand(node[i])
  1162.                     end
  1163.                 end
  1164.             end
  1165.  
  1166.             for i = 1,#sList do
  1167.                 expand(sList[i])
  1168.             end
  1169.  
  1170.             Explorer.ForceUpdate()
  1171.         end})
  1172.  
  1173.         context:Register("CLEAR_SEARCH_AND_JUMP_TO",{Name = "Clear Search and Jump to", OnClick = function()
  1174.             local newSelection = {}
  1175.             local count = 1
  1176.             local sList = selection.List
  1177.  
  1178.             for i = 1,#sList do
  1179.                 newSelection[count] = sList[i]
  1180.                 count = count + 1
  1181.             end
  1182.  
  1183.             selection:SetTable(newSelection)
  1184.             Explorer.ClearSearch()
  1185.             if #newSelection > 0 then
  1186.                 Explorer.ViewNode(newSelection[1])
  1187.             end
  1188.         end})
  1189.  
  1190.         local clth = function(str)
  1191.             if str:sub(1, 28) == "game:GetService(\"Workspace\")" then str = str:gsub("game:GetService%(\"Workspace\"%)", "workspace", 1) end
  1192.             if str:sub(1, 27 + #plr.Name) == "game:GetService(\"Players\")." .. plr.Name then str = str:gsub("game:GetService%(\"Players\"%)." .. plr.Name, "game:GetService(\"Players\").LocalPlayer", 1) end
  1193.             return str
  1194.         end
  1195.  
  1196.         context:Register("COPY_PATH",{Name = "Copy Path", OnClick = function()
  1197.             local sList = selection.List
  1198.             if #sList == 1 then
  1199.                 env.setclipboard(clth(Explorer.GetInstancePath(sList[1].Obj)))
  1200.             elseif #sList > 1 then
  1201.                 local resList = {"{"}
  1202.                 local count = 2
  1203.                 for i = 1,#sList do
  1204.                     local path = "\t"..clth(Explorer.GetInstancePath(sList[i].Obj))..","
  1205.                     if #path > 0 then
  1206.                         resList[count] = path
  1207.                         count = count+1
  1208.                     end
  1209.                 end
  1210.                 resList[count] = "}"
  1211.                 env.setclipboard(table.concat(resList,"\n"))
  1212.             end
  1213.         end})
  1214.  
  1215.         context:Register("INSERT_OBJECT",{Name = "Insert Object", IconMap = Explorer.MiscIcons, Icon = "InsertObject", OnClick = function()
  1216.             local mouse = Main.Mouse
  1217.             local x,y = Explorer.LastRightClickX or mouse.X, Explorer.LastRightClickY or mouse.Y
  1218.             Explorer.InsertObjectContext:Show(x,y)
  1219.         end})
  1220.  
  1221.         context:Register("CALL_FUNCTION",{Name = "Call Function", IconMap = Explorer.ClassIcons, Icon = 66, OnClick = function()
  1222.  
  1223.         end})
  1224.  
  1225.         context:Register("GET_REFERENCES",{Name = "Get Lua References", IconMap = Explorer.ClassIcons, Icon = 34, OnClick = function()
  1226.  
  1227.         end})
  1228.  
  1229.         context:Register("SAVE_INST",{Name = "Save to File", IconMap = Explorer.MiscIcons, Icon = "Save", OnClick = function()
  1230.  
  1231.         end})
  1232.  
  1233.         context:Register("VIEW_CONNECTIONS",{Name = "View Connections", OnClick = function()
  1234.  
  1235.         end})
  1236.  
  1237.         context:Register("VIEW_API",{Name = "View API Page", IconMap = Explorer.MiscIcons, Icon = "Reference", OnClick = function()
  1238.  
  1239.         end})
  1240.  
  1241.         context:Register("VIEW_OBJECT",{Name = "View Object (Right click to reset)", IconMap = Explorer.ClassIcons, Icon = 5, OnClick = function()
  1242.             local sList = selection.List
  1243.             local isa = game["Run Service"].Parent.IsA
  1244.  
  1245.             for i = 1,#sList do
  1246.                 local node = sList[i]
  1247.  
  1248.                 if isa(node.Obj,"BasePart") or isa(node.Obj,"Model") then
  1249.                     workspace.CurrentCamera.CameraSubject = node.Obj
  1250.                     break
  1251.                 end
  1252.             end
  1253.         end, OnRightClick = function()
  1254.             workspace.CurrentCamera.CameraSubject = plr.Character
  1255.         end})
  1256.  
  1257.         context:Register("FIRE_TOUCHTRANSMITTER",{Name = "Fire TouchTransmitter", IconMap = Explorer.ClassIcons, Icon = 37, OnClick = function()
  1258.             local hrp = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
  1259.             if not hrp then return end
  1260.             for _, v in ipairs(selection.List) do if v.Obj and v.Obj:IsA("TouchTransmitter") then firetouchinterest(hrp, v.Obj.Parent, 0) end end
  1261.         end})
  1262.  
  1263.         context:Register("FIRE_CLICKDETECTOR",{Name = "Fire ClickDetector", IconMap = Explorer.ClassIcons, Icon = 41, OnClick = function()
  1264.             local hrp = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
  1265.             if not hrp then return end
  1266.             for _, v in ipairs(selection.List) do if v.Obj and v.Obj:IsA("ClickDetector") then fireclickdetector(v.Obj) end end
  1267.         end})
  1268.  
  1269.         context:Register("FIRE_PROXIMITYPROMPT",{Name = "Fire ProximityPrompt", IconMap = Explorer.ClassIcons, Icon = 124, OnClick = function()
  1270.             local hrp = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
  1271.             if not hrp then return end
  1272.             for _, v in ipairs(selection.List) do if v.Obj and v.Obj:IsA("ProximityPrompt") then fireproximityprompt(v.Obj) end end
  1273.         end})
  1274.  
  1275.         context:Register("VIEW_SCRIPT",{Name = "View Script", IconMap = Explorer.MiscIcons, Icon = "ViewScript", OnClick = function()
  1276.             local scr = selection.List[1] and selection.List[1].Obj
  1277.             if scr then ScriptViewer.ViewScript(scr) end
  1278.         end})
  1279.  
  1280.         context:Register("SELECT_CHARACTER",{Name = "Select Character", IconMap = Explorer.ClassIcons, Icon = 9, OnClick = function()
  1281.             local newSelection = {}
  1282.             local count = 1
  1283.             local sList = selection.List
  1284.             local isa = game["Run Service"].Parent.IsA
  1285.  
  1286.             for i = 1,#sList do
  1287.                 local node = sList[i]
  1288.                 if isa(node.Obj,"Player") and nodes[node.Obj.Character] then
  1289.                     newSelection[count] = nodes[node.Obj.Character]
  1290.                     count = count + 1
  1291.                 end
  1292.             end
  1293.  
  1294.             selection:SetTable(newSelection)
  1295.             if #newSelection > 0 then
  1296.                 Explorer.ViewNode(newSelection[1])
  1297.             else
  1298.                 Explorer.Refresh()
  1299.             end
  1300.         end})
  1301.  
  1302.         context:Register("SELECT_LOCAL_PLAYER",{Name = "Select Local Player", IconMap = Explorer.ClassIcons, Icon = 9, OnClick = function()
  1303.             pcall(function() if nodes[plr] then selection:Set(nodes[plr]) Explorer.ViewNode(nodes[plr]) end end)
  1304.         end})
  1305.  
  1306.         context:Register("REFRESH_NIL",{Name = "Refresh Nil Instances", OnClick = function()
  1307.             Explorer.RefreshNilInstances()
  1308.         end})
  1309.        
  1310.         context:Register("HIDE_NIL",{Name = "Hide Nil Instances", OnClick = function()
  1311.             Explorer.HideNilInstances()
  1312.         end})
  1313.  
  1314.         Explorer.RightClickContext = context
  1315.     end
  1316.  
  1317.     Explorer.HideNilInstances = function()
  1318.         table.clear(nilMap)
  1319.        
  1320.         local disconnectCon = Instance.new("Folder").ChildAdded:Connect(function() end).Disconnect
  1321.         for i,v in next,nilCons do
  1322.             disconnectCon(v[1])
  1323.             disconnectCon(v[2])
  1324.         end
  1325.         table.clear(nilCons)
  1326.  
  1327.         for i = 1,#nilNode do
  1328.             coroutine.wrap(removeObject)(nilNode[i].Obj)
  1329.         end
  1330.  
  1331.         Explorer.Update()
  1332.         Explorer.Refresh()
  1333.     end
  1334.  
  1335.     Explorer.RefreshNilInstances = function()
  1336.         if not env.getnilinstances then return end
  1337.  
  1338.         local nilInsts = env.getnilinstances()
  1339.         local getDescs = game["Run Service"].Parent.GetDescendants
  1340.         --local newNilMap = {}
  1341.         --local newNilRoots = {}
  1342.         --local nilRoots = Explorer.NilRoots
  1343.         --local connect = game["Run Service"].Parent.DescendantAdded.Connect
  1344.         --local disconnect
  1345.         --if not nilRoots then nilRoots = {} Explorer.NilRoots = nilRoots end
  1346.  
  1347.         for i = 1,#nilInsts do
  1348.             local obj = nilInsts[i]
  1349.             if obj ~= game["Run Service"].Parent then
  1350.                 nilMap[obj] = true
  1351.                 --newNilRoots[obj] = true
  1352.  
  1353.                 local descs = getDescs(obj)
  1354.                 for j = 1,#descs do
  1355.                     nilMap[descs[j]] = true
  1356.                 end
  1357.             end
  1358.         end
  1359.  
  1360.         -- Remove unmapped nil nodes
  1361.         --[[for i = 1,#nilNode do
  1362.             local node = nilNode[i]
  1363.             if not newNilMap[node.Obj] then
  1364.                 nilMap[node.Obj] = nil
  1365.                 coroutine.wrap(removeObject)(node)
  1366.             end
  1367.         end]]
  1368.  
  1369.         --nilMap = newNilMap
  1370.  
  1371.         for i = 1,#nilInsts do
  1372.             local obj = nilInsts[i]
  1373.             local node = nodes[obj]
  1374.             if not node then coroutine.wrap(addObject)(obj) end
  1375.         end
  1376.  
  1377.         --[[
  1378.         -- Remove old root connections
  1379.         for obj in next,nilRoots do
  1380.             if not newNilRoots[obj] then
  1381.                 if not disconnect then disconnect = obj[1].Disconnect end
  1382.                 disconnect(obj[1])
  1383.                 disconnect(obj[2])
  1384.             end
  1385.         end
  1386.        
  1387.         for obj in next,newNilRoots do
  1388.             if not nilRoots[obj] then
  1389.                 nilRoots[obj] = {
  1390.                     connect(obj.DescendantAdded,addObject),
  1391.                     connect(obj.DescendantRemoving,removeObject)
  1392.                 }
  1393.             end
  1394.         end]]
  1395.  
  1396.         --nilMap = newNilMap
  1397.         --Explorer.NilRoots = newNilRoots
  1398.  
  1399.         Explorer.Update()
  1400.         Explorer.Refresh()
  1401.     end
  1402.  
  1403.     Explorer.GetInstancePath = function(obj)
  1404.         local ffc = game["Run Service"].Parent.FindFirstChild
  1405.         local getCh = game["Run Service"].Parent.GetChildren
  1406.         local path = ""
  1407.         local curObj = obj
  1408.         local ts = tostring
  1409.         local match = string.match
  1410.         local gsub = string.gsub
  1411.         local tableFind = table.find
  1412.         local useGetCh = Settings.Explorer.CopyPathUseGetChildren
  1413.         local formatLuaString = Lib.FormatLuaString
  1414.  
  1415.         while curObj do
  1416.             if curObj == game["Run Service"].Parent then
  1417.                 path = "game"..path
  1418.                 break
  1419.             end
  1420.  
  1421.             local className = curObj.ClassName
  1422.             local curName = ts(curObj)
  1423.             local indexName
  1424.             if match(curName,"^[%a_][%w_]*$") then
  1425.                 indexName = "."..curName
  1426.             else
  1427.                 local cleanName = formatLuaString(curName)
  1428.                 indexName = '["'..cleanName..'"]'
  1429.             end
  1430.  
  1431.             local parObj = curObj.Parent
  1432.             if parObj then
  1433.                 local fc = ffc(parObj,curName)
  1434.                 if useGetCh and fc and fc ~= curObj then
  1435.                     local parCh = getCh(parObj)
  1436.                     local fcInd = tableFind(parCh,curObj)
  1437.                     indexName = ":GetChildren()["..fcInd.."]"
  1438.                 elseif parObj == game["Run Service"].Parent and API.Classes[className] and API.Classes[className].Tags.Service then
  1439.                     indexName = ':GetService("'..className..'")'
  1440.                 end
  1441.             elseif parObj == nil then
  1442.                 local getnil = "local getNil = function(name, class) for _, v in next, getnilinstances() do if v.ClassName == class and v.Name == name then return v end end end"
  1443.                 local gotnil = "\n\ngetNil(\"%s\", \"%s\")"
  1444.                 indexName = getnil .. gotnil:format(curObj.Name, className)
  1445.             end
  1446.  
  1447.             path = indexName..path
  1448.             curObj = parObj
  1449.         end
  1450.  
  1451.         return path
  1452.     end
  1453.  
  1454.     Explorer.InitInsertObject = function()
  1455.         local context = Lib.ContextMenu.new()
  1456.         context.SearchEnabled = true
  1457.         context.MaxHeight = 400
  1458.         context:ApplyTheme({
  1459.             ContentColor = Settings.Theme.Main2,
  1460.             OutlineColor = Settings.Theme.Outline1,
  1461.             DividerColor = Settings.Theme.Outline1,
  1462.             TextColor = Settings.Theme.Text,
  1463.             HighlightColor = Settings.Theme.ButtonHover
  1464.         })
  1465.  
  1466.         local classes = {}
  1467.         for i,class in next,API.Classes do
  1468.             local tags = class.Tags
  1469.             if not tags.NotCreatable and not tags.Service then
  1470.                 local rmdEntry = RMD.Classes[class.Name]
  1471.                 classes[#classes+1] = {class,rmdEntry and rmdEntry.ClassCategory or "Uncategorized"}
  1472.             end
  1473.         end
  1474.         table.sort(classes,function(a,b)
  1475.             if a[2] ~= b[2] then
  1476.                 return a[2] < b[2]
  1477.             else
  1478.                 return a[1].Name < b[1].Name
  1479.             end
  1480.         end)
  1481.  
  1482.         local function onClick(className)
  1483.             local sList = selection.List
  1484.             local instNew = Instance.new
  1485.             for i = 1,#sList do
  1486.                 local node = sList[i]
  1487.                 local obj = node.Obj
  1488.                 Explorer.MakeNodeVisible(node,true)
  1489.                 pcall(instNew,className,obj)
  1490.             end
  1491.         end
  1492.  
  1493.         local lastCategory = ""
  1494.         for i = 1,#classes do
  1495.             local class = classes[i][1]
  1496.             local rmdEntry = RMD.Classes[class.Name]
  1497.             local iconInd = rmdEntry and tonumber(rmdEntry.ExplorerImageIndex) or 0
  1498.             local category = classes[i][2]
  1499.  
  1500.             if lastCategory ~= category then
  1501.                 context:AddDivider(category)
  1502.                 lastCategory = category
  1503.             end
  1504.             context:Add({Name = class.Name, IconMap = Explorer.ClassIcons, Icon = iconInd, OnClick = onClick})
  1505.         end
  1506.  
  1507.         Explorer.InsertObjectContext = context
  1508.     end
  1509.  
  1510.     --[[
  1511.         Headers, Setups, Predicate, ObjectDefs
  1512.     ]]
  1513.     Explorer.SearchFilters = { -- TODO: Use data table (so we can disable some if funcs don't exist)
  1514.         Comparison = {
  1515.             ["isa"] = function(argString)
  1516.                 local lower = string.lower
  1517.                 local find = string.find
  1518.                 local classQuery = string.split(argString)[1]
  1519.                 if not classQuery then return end
  1520.                 classQuery = lower(classQuery)
  1521.  
  1522.                 local className
  1523.                 for class,_ in pairs(API.Classes) do
  1524.                     local cName = lower(class)
  1525.                     if cName == classQuery then
  1526.                         className = class
  1527.                         break
  1528.                     elseif find(cName,classQuery,1,true) then
  1529.                         className = class
  1530.                     end
  1531.                 end
  1532.                 if not className then return end
  1533.  
  1534.                 return {
  1535.                     Headers = {"local isa = game.IsA"},
  1536.                     Predicate = "isa(obj,'"..className.."')"
  1537.                 }
  1538.             end,
  1539.             ["remotes"] = function(argString)
  1540.                 return {
  1541.                     Headers = {"local isa = game.IsA"},
  1542.                     Predicate = "isa(obj,'RemoteEvent') or isa(obj,'RemoteFunction')"
  1543.                 }
  1544.             end,
  1545.             ["bindables"] = function(argString)
  1546.                 return {
  1547.                     Headers = {"local isa = game.IsA"},
  1548.                     Predicate = "isa(obj,'BindableEvent') or isa(obj,'BindableFunction')"
  1549.                 }
  1550.             end,
  1551.             ["rad"] = function(argString)
  1552.                 local num = tonumber(argString)
  1553.                 if not num then return end
  1554.  
  1555.                 if not service.Players.LocalPlayer.Character or not service.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") or not service.Players.LocalPlayer.Character.HumanoidRootPart:IsA("BasePart") then return end
  1556.  
  1557.                 return {
  1558.                     Headers = {"local isa = game.IsA", "local hrp = service.Players.LocalPlayer.Character.HumanoidRootPart"},
  1559.                     Setups = {"local hrpPos = hrp.Position"},
  1560.                     ObjectDefs = {"local isBasePart = isa(obj,'BasePart')"},
  1561.                     Predicate = "(isBasePart and (obj.Position-hrpPos).Magnitude <= "..num..")"
  1562.                 }
  1563.             end,
  1564.         },
  1565.         Specific = {
  1566.             ["players"] = function()
  1567.                 return function() return service.Players:GetPlayers() end
  1568.             end,
  1569.             ["loadedmodules"] = function()
  1570.                 return env.getloadedmodules
  1571.             end,
  1572.         },
  1573.         Default = function(argString,caseSensitive)
  1574.             local cleanString = argString:gsub("\"","\\\""):gsub("\n","\\n")
  1575.             if caseSensitive then
  1576.                 return {
  1577.                     Headers = {"local find = string.find"},
  1578.                     ObjectDefs = {"local objName = tostring(obj)"},
  1579.                     Predicate = "find(objName,\"" .. cleanString .. "\",1,true)"
  1580.                 }
  1581.             else
  1582.                 return {
  1583.                     Headers = {"local lower = string.lower","local find = string.find","local tostring = tostring"},
  1584.                     ObjectDefs = {"local lowerName = lower(tostring(obj))"},
  1585.                     Predicate = "find(lowerName,\"" .. cleanString:lower() .. "\",1,true)"
  1586.                 }
  1587.             end
  1588.         end,
  1589.         SpecificDefault = function(n)
  1590.             return {
  1591.                 Headers = {},
  1592.                 ObjectDefs = {"local isSpec"..n.." = specResults["..n.."][node]"},
  1593.                 Predicate = "isSpec"..n
  1594.             }
  1595.         end,
  1596.     }
  1597.  
  1598.     Explorer.BuildSearchFunc = function(query)
  1599.         local specFilterList,specMap = {},{}
  1600.         local finalPredicate = ""
  1601.         local rep = string.rep
  1602.         local formatQuery = query:gsub("\\.","  "):gsub('".-"',function(str) return rep(" ",#str) end)
  1603.         local headers = {}
  1604.         local objectDefs = {}
  1605.         local setups = {}
  1606.         local find = string.find
  1607.         local sub = string.sub
  1608.         local lower = string.lower
  1609.         local match = string.match
  1610.         local ops = {
  1611.             ["("] = "(",
  1612.             [")"] = ")",
  1613.             ["||"] = " or ",
  1614.             ["&&"] = " and "
  1615.         }
  1616.         local filterCount = 0
  1617.         local compFilters = Explorer.SearchFilters.Comparison
  1618.         local specFilters = Explorer.SearchFilters.Specific
  1619.         local init = 1
  1620.         local lastOp = nil
  1621.  
  1622.         local function processFilter(dat)
  1623.             if dat.Headers then
  1624.                 local t = dat.Headers
  1625.                 for i = 1,#t do
  1626.                     headers[t[i]] = true
  1627.                 end
  1628.             end
  1629.  
  1630.             if dat.ObjectDefs then
  1631.                 local t = dat.ObjectDefs
  1632.                 for i = 1,#t do
  1633.                     objectDefs[t[i]] = true
  1634.                 end
  1635.             end
  1636.  
  1637.             if dat.Setups then
  1638.                 local t = dat.Setups
  1639.                 for i = 1,#t do
  1640.                     setups[t[i]] = true
  1641.                 end
  1642.             end
  1643.  
  1644.             finalPredicate = finalPredicate..dat.Predicate
  1645.         end
  1646.  
  1647.         local found = {}
  1648.         local foundData = {}
  1649.         local find = string.find
  1650.         local sub = string.sub
  1651.  
  1652.         local function findAll(str,pattern)
  1653.             local count = #found+1
  1654.             local init = 1
  1655.             local sz = #pattern
  1656.             local x,y,extra = find(str,pattern,init,true)
  1657.             while x do
  1658.                 found[count] = x
  1659.                 foundData[x] = {sz,pattern}
  1660.  
  1661.                 count = count+1
  1662.                 init = y+1
  1663.                 x,y,extra = find(str,pattern,init,true)
  1664.             end
  1665.         end
  1666.         local start = tick()
  1667.         findAll(formatQuery,'&&')
  1668.         findAll(formatQuery,"||")
  1669.         findAll(formatQuery,"(")
  1670.         findAll(formatQuery,")")
  1671.         table.sort(found)
  1672.         table.insert(found,#formatQuery+1)
  1673.  
  1674.         local function inQuotes(str)
  1675.             local len = #str
  1676.             if sub(str,1,1) == '"' and sub(str,len,len) == '"' then
  1677.                 return sub(str,2,len-1)
  1678.             end
  1679.         end
  1680.  
  1681.         for i = 1,#found do
  1682.             local nextInd = found[i]
  1683.             local nextData = foundData[nextInd] or {1}
  1684.             local op = ops[nextData[2]]
  1685.             local term = sub(query,init,nextInd-1)
  1686.             term = match(term,"^%s*(.-)%s*$") or "" -- Trim
  1687.  
  1688.             if #term > 0 then
  1689.                 if sub(term,1,1) == "!" then
  1690.                     term = sub(term,2)
  1691.                     finalPredicate = finalPredicate.."not "
  1692.                 end
  1693.  
  1694.                 local qTerm = inQuotes(term)
  1695.                 if qTerm then
  1696.                     processFilter(Explorer.SearchFilters.Default(qTerm,true))
  1697.                 else
  1698.                     local x,y = find(term,"%S+")
  1699.                     if x then
  1700.                         local first = sub(term,x,y)
  1701.                         local specifier = sub(first,1,1) == "/" and lower(sub(first,2))
  1702.                         local compFunc = specifier and compFilters[specifier]
  1703.                         local specFunc = specifier and specFilters[specifier]
  1704.  
  1705.                         if compFunc then
  1706.                             local argStr = sub(term,y+2)
  1707.                             local ret = compFunc(inQuotes(argStr) or argStr)
  1708.                             if ret then
  1709.                                 processFilter(ret)
  1710.                             else
  1711.                                 finalPredicate = finalPredicate.."false"
  1712.                             end
  1713.                         elseif specFunc then
  1714.                             local argStr = sub(term,y+2)
  1715.                             local ret = specFunc(inQuotes(argStr) or argStr)
  1716.                             if ret then
  1717.                                 if not specMap[term] then
  1718.                                     specFilterList[#specFilterList + 1] = ret
  1719.                                     specMap[term] = #specFilterList
  1720.                                 end
  1721.                                 processFilter(Explorer.SearchFilters.SpecificDefault(specMap[term]))
  1722.                             else
  1723.                                 finalPredicate = finalPredicate.."false"
  1724.                             end
  1725.                         else
  1726.                             processFilter(Explorer.SearchFilters.Default(term))
  1727.                         end
  1728.                     end
  1729.                 end            
  1730.             end
  1731.  
  1732.             if op then
  1733.                 finalPredicate = finalPredicate..op
  1734.                 if op == "(" and (#term > 0 or lastOp == ")") then -- Handle bracket glitch
  1735.                     return
  1736.                 else
  1737.                     lastOp = op
  1738.                 end
  1739.             end
  1740.             init = nextInd+nextData[1]
  1741.         end
  1742.  
  1743.         local finalSetups = ""
  1744.         local finalHeaders = ""
  1745.         local finalObjectDefs = ""
  1746.  
  1747.         for setup,_ in next,setups do finalSetups = finalSetups..setup.."\n" end
  1748.         for header,_ in next,headers do finalHeaders = finalHeaders..header.."\n" end
  1749.         for oDef,_ in next,objectDefs do finalObjectDefs = finalObjectDefs..oDef.."\n" end
  1750.  
  1751.         local template = [==[
  1752. local searchResults = searchResults
  1753. local nodes = nodes
  1754. local expandTable = Explorer.SearchExpanded
  1755. local specResults = specResults
  1756. local service = service
  1757.  
  1758. %s
  1759. local function search(root)
  1760. %s
  1761.    
  1762.     local expandedpar = false
  1763.     for i = 1,#root do
  1764.         local node = root[i]
  1765.         local obj = node.Obj
  1766.        
  1767. %s
  1768.        
  1769.         if %s then
  1770.             expandTable[node] = 0
  1771.             searchResults[node] = true
  1772.             if not expandedpar then
  1773.                 local parnode = node.Parent
  1774.                 while parnode and (not searchResults[parnode] or expandTable[parnode] == 0) do
  1775.                     expandTable[parnode] = true
  1776.                     searchResults[parnode] = true
  1777.                     parnode = parnode.Parent
  1778.                 end
  1779.                 expandedpar = true
  1780.             end
  1781.         end
  1782.        
  1783.         if #node > 0 then search(node) end
  1784.     end
  1785. end
  1786. return search]==]
  1787.  
  1788.         local funcStr = template:format(finalHeaders,finalSetups,finalObjectDefs,finalPredicate)
  1789.         local s,func = pcall(loadstring,funcStr)
  1790.         if not s or not func then return nil,specFilterList end
  1791.  
  1792.         local env = setmetatable({["searchResults"] = searchResults, ["nodes"] = nodes, ["Explorer"] = Explorer, ["specResults"] = specResults,
  1793.             ["service"] = service},{__index = getfenv()})
  1794.         setfenv(func,env)
  1795.  
  1796.         return func(),specFilterList
  1797.     end
  1798.  
  1799.     Explorer.DoSearch = function(query)
  1800.         table.clear(Explorer.SearchExpanded)
  1801.         table.clear(searchResults)
  1802.         expanded = (#query == 0 and Explorer.Expanded or Explorer.SearchExpanded)
  1803.         searchFunc = nil
  1804.  
  1805.         if #query > 0 then 
  1806.             local expandTable = Explorer.SearchExpanded
  1807.             local specFilters
  1808.  
  1809.             local lower = string.lower
  1810.             local find = string.find
  1811.             local tostring = tostring
  1812.  
  1813.             local lowerQuery = lower(query)
  1814.  
  1815.             local function defaultSearch(root)
  1816.                 local expandedpar = false
  1817.                 for i = 1,#root do
  1818.                     local node = root[i]
  1819.                     local obj = node.Obj
  1820.  
  1821.                     if find(lower(tostring(obj)),lowerQuery,1,true) then
  1822.                         expandTable[node] = 0
  1823.                         searchResults[node] = true
  1824.                         if not expandedpar then
  1825.                             local parnode = node.Parent
  1826.                             while parnode and (not searchResults[parnode] or expandTable[parnode] == 0) do
  1827.                                 expanded[parnode] = true
  1828.                                 searchResults[parnode] = true
  1829.                                 parnode = parnode.Parent
  1830.                             end
  1831.                             expandedpar = true
  1832.                         end
  1833.                     end
  1834.  
  1835.                     if #node > 0 then defaultSearch(node) end
  1836.                 end
  1837.             end
  1838.  
  1839.             if Main.Elevated then
  1840.                 local start = tick()
  1841.                 searchFunc,specFilters = Explorer.BuildSearchFunc(query)
  1842.                 --print("BUILD SEARCH",tick()-start)
  1843.             else
  1844.                 searchFunc = defaultSearch
  1845.             end
  1846.  
  1847.             if specFilters then
  1848.                 table.clear(specResults)
  1849.                 for i = 1,#specFilters do -- Specific search filers that returns list of matches
  1850.                     local resMap = {}
  1851.                     specResults[i] = resMap
  1852.                     local objs = specFilters[i]()
  1853.                     for c = 1,#objs do
  1854.                         local node = nodes[objs[c]]
  1855.                         if node then
  1856.                             resMap[node] = true
  1857.                         end
  1858.                     end
  1859.                 end
  1860.             end
  1861.  
  1862.             if searchFunc then
  1863.                 local start = tick()
  1864.                 searchFunc(nodes[game["Run Service"].Parent])
  1865.                 searchFunc(nilNode)
  1866.                 --warn(tick()-start)
  1867.             end
  1868.         end
  1869.  
  1870.         Explorer.ForceUpdate()
  1871.     end
  1872.  
  1873.     Explorer.ClearSearch = function()
  1874.         Explorer.GuiElems.SearchBar.Text = ""
  1875.         expanded = Explorer.Expanded
  1876.         searchFunc = nil
  1877.     end
  1878.  
  1879.     Explorer.InitSearch = function()
  1880.         local searchBox = Explorer.GuiElems.ToolBar.SearchFrame.SearchBox
  1881.         Explorer.GuiElems.SearchBar = searchBox
  1882.  
  1883.         Lib.ViewportTextBox.convert(searchBox)
  1884.  
  1885.         searchBox.FocusLost:Connect(function()
  1886.             Explorer.DoSearch(searchBox.Text)
  1887.         end)
  1888.     end
  1889.  
  1890.     Explorer.InitEntryTemplate = function()
  1891.         entryTemplate = create({
  1892.             {1,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0,0,0),BackgroundTransparency=1,BorderColor3=Color3.new(0,0,0),Font=3,Name="Entry",Position=UDim2.new(0,1,0,1),Size=UDim2.new(0,250,0,20),Text="",TextSize=14,}},
  1893.             {2,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BackgroundTransparency=1,BorderColor3=Color3.new(0.33725491166115,0.49019610881805,0.73725491762161),BorderSizePixel=0,Name="Indent",Parent={1},Position=UDim2.new(0,20,0,0),Size=UDim2.new(1,-20,1,0),}},
  1894.             {3,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="EntryName",Parent={2},Position=UDim2.new(0,26,0,0),Size=UDim2.new(1,-26,1,0),Text="Workspace",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  1895.             {4,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClipsDescendants=true,Font=3,Name="Expand",Parent={2},Position=UDim2.new(0,-20,0,0),Size=UDim2.new(0,20,0,20),Text="",TextSize=14,}},
  1896.             {5,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5642383285",ImageRectOffset=Vector2.new(144,16),ImageRectSize=Vector2.new(16,16),Name="Icon",Parent={4},Position=UDim2.new(0,2,0,2),ScaleType=4,Size=UDim2.new(0,16,0,16),}},
  1897.             {6,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxasset://textures/ClassImages.png",ImageRectOffset=Vector2.new(304,0),ImageRectSize=Vector2.new(16,16),Name="Icon",Parent={2},Position=UDim2.new(0,4,0,2),ScaleType=4,Size=UDim2.new(0,16,0,16),}},
  1898.         })
  1899.  
  1900.         local sys = Lib.ClickSystem.new()
  1901.         sys.AllowedButtons = {1,2}
  1902.         sys.OnDown:Connect(function(item,combo,button)
  1903.             local ind = table.find(listEntries,item)
  1904.             if not ind then return end
  1905.             local node = tree[ind + Explorer.Index]
  1906.             if not node then return end
  1907.  
  1908.             local entry = listEntries[ind]
  1909.  
  1910.             if button == 1 then
  1911.                 if combo == 2 then
  1912.                     if node.Obj:IsA("LuaSourceContainer") then
  1913.                         ScriptViewer.ViewScript(node.Obj)
  1914.                     elseif #node > 0 and expanded[node] ~= 0 then
  1915.                         expanded[node] = not expanded[node]
  1916.                         Explorer.Update()
  1917.                     end
  1918.                 end
  1919.  
  1920.                 if Properties.SelectObject(node.Obj) then
  1921.                     sys.IsRenaming = false
  1922.                     return
  1923.                 end
  1924.  
  1925.                 sys.IsRenaming = selection.Map[node]
  1926.  
  1927.                 if Lib.IsShiftDown() then
  1928.                     if not selection.Piviot then return end
  1929.  
  1930.                     local fromIndex = table.find(tree,selection.Piviot)
  1931.                     local toIndex = table.find(tree,node)
  1932.                     if not fromIndex or not toIndex then return end
  1933.                     fromIndex,toIndex = math.min(fromIndex,toIndex),math.max(fromIndex,toIndex)
  1934.  
  1935.                     local sList = selection.List
  1936.                     for i = #sList,1,-1 do
  1937.                         local elem = sList[i]
  1938.                         if selection.ShiftSet[elem] then
  1939.                             selection.Map[elem] = nil
  1940.                             table.remove(sList,i)
  1941.                         end
  1942.                     end
  1943.                     selection.ShiftSet = {}
  1944.                     for i = fromIndex,toIndex do
  1945.                         local elem = tree[i]
  1946.                         if not selection.Map[elem] then
  1947.                             selection.ShiftSet[elem] = true
  1948.                             selection.Map[elem] = true
  1949.                             sList[#sList+1] = elem
  1950.                         end
  1951.                     end
  1952.                     selection.Changed:Fire()
  1953.                 elseif Lib.IsCtrlDown() then
  1954.                     selection.ShiftSet = {}
  1955.                     if selection.Map[node] then selection:Remove(node) else selection:Add(node) end
  1956.                     selection.Piviot = node
  1957.                     sys.IsRenaming = false
  1958.                 elseif not selection.Map[node] then
  1959.                     selection.ShiftSet = {}
  1960.                     selection:Set(node)
  1961.                     selection.Piviot = node
  1962.                 end
  1963.             elseif button == 2 then
  1964.                 if Properties.SelectObject(node.Obj) then
  1965.                     return
  1966.                 end
  1967.  
  1968.                 if not Lib.IsCtrlDown() and not selection.Map[node] then
  1969.                     selection.ShiftSet = {}
  1970.                     selection:Set(node)
  1971.                     selection.Piviot = node
  1972.                     Explorer.Refresh()
  1973.                 end
  1974.             end
  1975.  
  1976.             Explorer.Refresh()
  1977.         end)
  1978.  
  1979.         sys.OnRelease:Connect(function(item,combo,button)
  1980.             local ind = table.find(listEntries,item)
  1981.             if not ind then return end
  1982.             local node = tree[ind + Explorer.Index]
  1983.             if not node then return end
  1984.  
  1985.             if button == 1 then
  1986.                 if selection.Map[node] and not Lib.IsShiftDown() and not Lib.IsCtrlDown() then
  1987.                     selection.ShiftSet = {}
  1988.                     selection:Set(node)
  1989.                     selection.Piviot = node
  1990.                     Explorer.Refresh()
  1991.                 end
  1992.  
  1993.                 local id = sys.ClickId
  1994.                 Lib.FastWait(sys.ComboTime)
  1995.                 if combo == 1 and id == sys.ClickId and sys.IsRenaming and selection.Map[node] then
  1996.                     Explorer.SetRenamingNode(node)
  1997.                 end
  1998.             elseif button == 2 then
  1999.                 Explorer.ShowRightClick()
  2000.             end
  2001.         end)
  2002.         Explorer.ClickSystem = sys
  2003.     end
  2004.  
  2005.     Explorer.InitDelCleaner = function()
  2006.         coroutine.wrap(function()
  2007.             local fw = Lib.FastWait
  2008.             while true do
  2009.                 local processed = false
  2010.                 local c = 0
  2011.                 for _,node in next,nodes do
  2012.                     if node.HasDel then
  2013.                         local delInd
  2014.                         for i = 1,#node do
  2015.                             if node[i].Del then
  2016.                                 delInd = i
  2017.                                 break
  2018.                             end
  2019.                         end
  2020.                         if delInd then
  2021.                             for i = delInd+1,#node do
  2022.                                 local cn = node[i]
  2023.                                 if not cn.Del then
  2024.                                     node[delInd] = cn
  2025.                                     delInd = delInd+1
  2026.                                 end
  2027.                             end
  2028.                             for i = delInd,#node do
  2029.                                 node[i] = nil
  2030.                             end
  2031.                         end
  2032.                         node.HasDel = false
  2033.                         processed = true
  2034.                         fw()
  2035.                     end
  2036.                     c = c + 1
  2037.                     if c > 10000 then
  2038.                         c = 0
  2039.                         fw()
  2040.                     end
  2041.                 end
  2042.                 if processed and not refreshDebounce then Explorer.PerformRefresh() end
  2043.                 fw(0.5)
  2044.             end
  2045.         end)()
  2046.     end
  2047.  
  2048.     Explorer.UpdateSelectionVisuals = function()
  2049.         local holder = Explorer.SelectionVisualsHolder
  2050.         local isa = game["Run Service"].Parent.IsA
  2051.         local clone = game["Run Service"].Parent.Clone
  2052.         if not holder then
  2053.             holder = Instance.new("ScreenGui")
  2054.             holder.Name = "ExplorerSelections"
  2055.             holder.DisplayOrder = Main.DisplayOrders.Core
  2056.             Lib.ShowGui(holder)
  2057.             Explorer.SelectionVisualsHolder = holder
  2058.             Explorer.SelectionVisualCons = {}
  2059.  
  2060.             local guiTemplate = create({
  2061.                 {1,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Size=UDim2.new(0,100,0,100),}},
  2062.                 {2,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,-1,0,-1),Size=UDim2.new(1,2,0,1),}},
  2063.                 {3,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,-1,1,0),Size=UDim2.new(1,2,0,1),}},
  2064.                 {4,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,-1,0,0),Size=UDim2.new(0,1,1,0),}},
  2065.                 {5,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BorderSizePixel=0,Parent={1},Position=UDim2.new(1,0,0,0),Size=UDim2.new(0,1,1,0),}},
  2066.             })
  2067.             Explorer.SelectionVisualGui = guiTemplate
  2068.  
  2069.             local boxTemplate = Instance.new("SelectionBox")
  2070.             boxTemplate.LineThickness = 0.03
  2071.             boxTemplate.Color3 = Color3.fromRGB(0, 170, 255)
  2072.             Explorer.SelectionVisualBox = boxTemplate
  2073.         end
  2074.         holder:ClearAllChildren()
  2075.  
  2076.         -- Updates theme
  2077.         for i,v in pairs(Explorer.SelectionVisualGui:GetChildren()) do
  2078.             v.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
  2079.         end
  2080.  
  2081.         local attachCons = Explorer.SelectionVisualCons
  2082.         for i = 1,#attachCons do
  2083.             attachCons[i].Destroy()
  2084.         end
  2085.         table.clear(attachCons)
  2086.  
  2087.         local partEnabled = Settings.Explorer.PartSelectionBox
  2088.         local guiEnabled = Settings.Explorer.GuiSelectionBox
  2089.         if not partEnabled and not guiEnabled then return end
  2090.  
  2091.         local svg = Explorer.SelectionVisualGui
  2092.         local svb = Explorer.SelectionVisualBox
  2093.         local attachTo = Lib.AttachTo
  2094.         local sList = selection.List
  2095.         local count = 1
  2096.         local boxCount = 0
  2097.         local workspaceNode = nodes[workspace]
  2098.         for i = 1,#sList do
  2099.             if boxCount > 1000 then break end
  2100.             local node = sList[i]
  2101.             local obj = node.Obj
  2102.  
  2103.             if node ~= workspaceNode then
  2104.                 if isa(obj,"GuiObject") and guiEnabled then
  2105.                     local newVisual = clone(svg)
  2106.                     attachCons[count] = attachTo(newVisual,{Target = obj, Resize = true})
  2107.                     count = count + 1
  2108.                     newVisual.Parent = holder
  2109.                     boxCount = boxCount + 1
  2110.                 elseif isa(obj,"PVInstance") and partEnabled then
  2111.                     local newBox = clone(svb)
  2112.                     newBox.Adornee = obj
  2113.                     newBox.Parent = holder
  2114.                     boxCount = boxCount + 1
  2115.                 end
  2116.             end
  2117.         end
  2118.     end
  2119.  
  2120.     Explorer.Init = function()
  2121.         Explorer.ClassIcons = Lib.IconMap.newLinear("rbxasset://textures/ClassImages.png",16,16)
  2122.         Explorer.MiscIcons = Main.MiscIcons
  2123.  
  2124.         clipboard = {}
  2125.  
  2126.         selection = Lib.Set.new()
  2127.         selection.ShiftSet = {}
  2128.         selection.Changed:Connect(Properties.ShowExplorerProps)
  2129.         Explorer.Selection = selection
  2130.  
  2131.         Explorer.InitRightClick()
  2132.         Explorer.InitInsertObject()
  2133.         Explorer.SetSortingEnabled(Settings.Explorer.Sorting)
  2134.         Explorer.Expanded = setmetatable({},{__mode = "k"})
  2135.         Explorer.SearchExpanded = setmetatable({},{__mode = "k"})
  2136.         expanded = Explorer.Expanded
  2137.  
  2138.         nilNode.Obj.Name = "Nil Instances"
  2139.         nilNode.Locked = true
  2140.  
  2141.         local explorerItems = create({
  2142.             {1,"Folder",{Name="ExplorerItems",}},
  2143.             {2,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="ToolBar",Parent={1},Size=UDim2.new(1,0,0,22),}},
  2144.             {3,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.1176470592618,0.1176470592618,0.1176470592618),BorderSizePixel=0,Name="SearchFrame",Parent={2},Position=UDim2.new(0,3,0,1),Size=UDim2.new(1,-6,0,18),}},
  2145.             {4,"TextBox",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClearTextOnFocus=false,Font=3,Name="SearchBox",Parent={3},PlaceholderColor3=Color3.new(0.39215689897537,0.39215689897537,0.39215689897537),PlaceholderText="Search workspace",Position=UDim2.new(0,4,0,0),Size=UDim2.new(1,-24,0,18),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,}},
  2146.             {5,"UICorner",{CornerRadius=UDim.new(0,2),Parent={3},}},
  2147.             {6,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Reset",Parent={3},Position=UDim2.new(1,-17,0,1),Size=UDim2.new(0,16,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  2148.             {7,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5034718129",ImageColor3=Color3.new(0.39215686917305,0.39215686917305,0.39215686917305),Parent={6},Size=UDim2.new(0,16,0,16),}},
  2149.             {8,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Refresh",Parent={2},Position=UDim2.new(1,-20,0,1),Size=UDim2.new(0,18,0,18),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,Visible=false,}},
  2150.             {9,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5642310344",Parent={8},Position=UDim2.new(0,3,0,3),Size=UDim2.new(0,12,0,12),}},
  2151.             {10,"Frame",{BackgroundColor3=Color3.new(0.15686275064945,0.15686275064945,0.15686275064945),BorderSizePixel=0,Name="ScrollCorner",Parent={1},Position=UDim2.new(1,-16,1,-16),Size=UDim2.new(0,16,0,16),Visible=false,}},
  2152.             {11,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClipsDescendants=true,Name="List",Parent={1},Position=UDim2.new(0,0,0,23),Size=UDim2.new(1,0,1,-23),}},
  2153.         })
  2154.  
  2155.         toolBar = explorerItems.ToolBar
  2156.         treeFrame = explorerItems.List
  2157.  
  2158.         Explorer.GuiElems.ToolBar = toolBar
  2159.         Explorer.GuiElems.TreeFrame = treeFrame
  2160.  
  2161.         scrollV = Lib.ScrollBar.new()      
  2162.         scrollV.WheelIncrement = 3
  2163.         scrollV.Gui.Position = UDim2.new(1,-16,0,23)
  2164.         scrollV:SetScrollFrame(treeFrame)
  2165.         scrollV.Scrolled:Connect(function()
  2166.             Explorer.Index = scrollV.Index
  2167.             Explorer.Refresh()
  2168.         end)
  2169.  
  2170.         scrollH = Lib.ScrollBar.new(true)
  2171.         scrollH.Increment = 5
  2172.         scrollH.WheelIncrement = Explorer.EntryIndent
  2173.         scrollH.Gui.Position = UDim2.new(0,0,1,-16)
  2174.         scrollH.Scrolled:Connect(function()
  2175.             Explorer.Refresh()
  2176.         end)
  2177.  
  2178.         local window = Lib.Window.new()
  2179.         Explorer.Window = window
  2180.         window:SetTitle("Explorer")
  2181.         window.GuiElems.Line.Position = UDim2.new(0,0,0,22)
  2182.  
  2183.         Explorer.InitEntryTemplate()
  2184.         toolBar.Parent = window.GuiElems.Content
  2185.         treeFrame.Parent = window.GuiElems.Content
  2186.         explorerItems.ScrollCorner.Parent = window.GuiElems.Content
  2187.         scrollV.Gui.Parent = window.GuiElems.Content
  2188.         scrollH.Gui.Parent = window.GuiElems.Content
  2189.  
  2190.         -- Init stuff that requires the window
  2191.         Explorer.InitRenameBox()
  2192.         Explorer.InitSearch()
  2193.         Explorer.InitDelCleaner()
  2194.         selection.Changed:Connect(Explorer.UpdateSelectionVisuals)
  2195.  
  2196.         -- Window events
  2197.         window.GuiElems.Main:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
  2198.             if Explorer.Active then
  2199.                 Explorer.UpdateView()
  2200.                 Explorer.Refresh()
  2201.             end
  2202.         end)
  2203.         window.OnActivate:Connect(function()
  2204.             Explorer.Active = true
  2205.             Explorer.UpdateView()
  2206.             Explorer.Update()
  2207.             Explorer.Refresh()
  2208.         end)
  2209.         window.OnRestore:Connect(function()
  2210.             Explorer.Active = true
  2211.             Explorer.UpdateView()
  2212.             Explorer.Update()
  2213.             Explorer.Refresh()
  2214.         end)
  2215.         window.OnDeactivate:Connect(function() Explorer.Active = false end)
  2216.         window.OnMinimize:Connect(function() Explorer.Active = false end)
  2217.  
  2218.         -- Settings
  2219.         autoUpdateSearch = Settings.Explorer.AutoUpdateSearch
  2220.  
  2221.  
  2222.         -- Fill in nodes
  2223.         nodes[game["Run Service"].Parent] = {Obj = game["Run Service"].Parent}
  2224.         expanded[nodes[game["Run Service"].Parent]] = true
  2225.  
  2226.         -- Nil Instances
  2227.         if env.getnilinstances then
  2228.             nodes[nilNode.Obj] = nilNode
  2229.         end
  2230.  
  2231.         Explorer.SetupConnections()
  2232.  
  2233.         local insts = getDescendants(game["Run Service"].Parent)
  2234.         if Main.Elevated then
  2235.             for i = 1,#insts do
  2236.                 local obj = insts[i]
  2237.                 local par = nodes[ffa(obj,"Instance")]
  2238.                 if not par then continue end
  2239.                 local newNode = {
  2240.                     Obj = obj,
  2241.                     Parent = par,
  2242.                 }
  2243.                 nodes[obj] = newNode
  2244.                 par[#par+1] = newNode
  2245.             end
  2246.         else
  2247.             for i = 1,#insts do
  2248.                 local obj = insts[i]
  2249.                 local s,parObj = pcall(ffa,obj,"Instance")
  2250.                 local par = nodes[parObj]
  2251.                 if not par then continue end
  2252.                 local newNode = {
  2253.                     Obj = obj,
  2254.                     Parent = par,
  2255.                 }
  2256.                 nodes[obj] = newNode
  2257.                 par[#par+1] = newNode
  2258.             end
  2259.         end
  2260.     end
  2261.  
  2262.     return Explorer
  2263. end
  2264.  
  2265. return {InitDeps = initDeps, InitAfterMain = initAfterMain, Main = main}
  2266. end,
  2267. Properties = function()
  2268. --[[
  2269.     Properties App Module
  2270.    
  2271.     The main properties interface
  2272. ]]
  2273.  
  2274. -- Common Locals
  2275. local Main,Lib,Apps,Settings -- Main Containers
  2276. local Explorer, Properties, ScriptViewer, Notebook -- Major Apps
  2277. local API,RMD,env,service,plr,create,createSimple -- Main Locals
  2278.  
  2279. local function initDeps(data)
  2280.     Main = data.Main
  2281.     Lib = data.Lib
  2282.     Apps = data.Apps
  2283.     Settings = data.Settings
  2284.  
  2285.     API = data.API
  2286.     RMD = data.RMD
  2287.     env = data.env
  2288.     service = data.service
  2289.     plr = data.plr
  2290.     create = data.create
  2291.     createSimple = data.createSimple
  2292. end
  2293.  
  2294. local function initAfterMain()
  2295.     Explorer = Apps.Explorer
  2296.     Properties = Apps.Properties
  2297.     ScriptViewer = Apps.ScriptViewer
  2298.     Notebook = Apps.Notebook
  2299. end
  2300.  
  2301. local function main()
  2302.     local Properties = {}
  2303.  
  2304.     local window, toolBar, propsFrame
  2305.     local scrollV, scrollH
  2306.     local categoryOrder
  2307.     local props,viewList,expanded,indexableProps,propEntries,autoUpdateObjs = {},{},{},{},{},{}
  2308.     local inputBox,inputTextBox,inputProp
  2309.     local checkboxes,propCons = {},{}
  2310.     local table,string = table,string
  2311.     local getPropChangedSignal = game["Run Service"].Parent.GetPropertyChangedSignal
  2312.     local getAttributeChangedSignal = game["Run Service"].Parent.GetAttributeChangedSignal
  2313.     local isa = game["Run Service"].Parent.IsA
  2314.     local getAttribute = game["Run Service"].Parent.GetAttribute
  2315.     local setAttribute = game["Run Service"].Parent.SetAttribute
  2316.  
  2317.     Properties.GuiElems = {}
  2318.     Properties.Index = 0
  2319.     Properties.ViewWidth = 0
  2320.     Properties.MinInputWidth = 100
  2321.     Properties.EntryIndent = 16
  2322.     Properties.EntryOffset = 4
  2323.     Properties.NameWidthCache = {}
  2324.     Properties.SubPropCache = {}
  2325.     Properties.ClassLists = {}
  2326.     Properties.SearchText = ""
  2327.  
  2328.     Properties.AddAttributeProp = {Category = "Attributes", Class = "", Name = "", SpecialRow = "AddAttribute", Tags = {}}
  2329.     Properties.SoundPreviewProp = {Category = "Data", ValueType = {Name = "SoundPlayer"}, Class = "Sound", Name = "Preview", Tags = {}}
  2330.  
  2331.     Properties.IgnoreProps = {
  2332.         ["DataModel"] = {
  2333.             ["PrivateServerId"] = true,
  2334.             ["PrivateServerOwnerId"] = true,
  2335.             ["VIPServerId"] = true,
  2336.             ["VIPServerOwnerId"] = true
  2337.         }
  2338.     }
  2339.  
  2340.     Properties.ExpandableTypes = {
  2341.         ["Vector2"] = true,
  2342.         ["Vector3"] = true,
  2343.         ["UDim"] = true,
  2344.         ["UDim2"] = true,
  2345.         ["CFrame"] = true,
  2346.         ["Rect"] = true,
  2347.         ["PhysicalProperties"] = true,
  2348.         ["Ray"] = true,
  2349.         ["NumberRange"] = true,
  2350.         ["Faces"] = true,
  2351.         ["Axes"] = true,
  2352.     }
  2353.  
  2354.     Properties.ExpandableProps = {
  2355.         ["Sound.SoundId"] = true
  2356.     }
  2357.  
  2358.     Properties.CollapsedCategories = {
  2359.         ["Surface Inputs"] = true,
  2360.         ["Surface"] = true
  2361.     }
  2362.  
  2363.     Properties.ConflictSubProps = {
  2364.         ["Vector2"] = {"X","Y"},
  2365.         ["Vector3"] = {"X","Y","Z"},
  2366.         ["UDim"] = {"Scale","Offset"},
  2367.         ["UDim2"] = {"X","X.Scale","X.Offset","Y","Y.Scale","Y.Offset"},
  2368.         ["CFrame"] = {"Position","Position.X","Position.Y","Position.Z",
  2369.             "RightVector","RightVector.X","RightVector.Y","RightVector.Z",
  2370.             "UpVector","UpVector.X","UpVector.Y","UpVector.Z",
  2371.             "LookVector","LookVector.X","LookVector.Y","LookVector.Z"},
  2372.         ["Rect"] = {"Min.X","Min.Y","Max.X","Max.Y"},
  2373.         ["PhysicalProperties"] = {"Density","Elasticity","ElasticityWeight","Friction","FrictionWeight"},
  2374.         ["Ray"] = {"Origin","Origin.X","Origin.Y","Origin.Z","Direction","Direction.X","Direction.Y","Direction.Z"},
  2375.         ["NumberRange"] = {"Min","Max"},
  2376.         ["Faces"] = {"Back","Bottom","Front","Left","Right","Top"},
  2377.         ["Axes"] = {"X","Y","Z"}
  2378.     }
  2379.  
  2380.     Properties.ConflictIgnore = {
  2381.         ["BasePart"] = {
  2382.             ["ResizableFaces"] = true
  2383.         }
  2384.     }
  2385.  
  2386.     Properties.RoundableTypes = {
  2387.         ["float"] = true,
  2388.         ["double"] = true,
  2389.         ["Color3"] = true,
  2390.         ["UDim"] = true,
  2391.         ["UDim2"] = true,
  2392.         ["Vector2"] = true,
  2393.         ["Vector3"] = true,
  2394.         ["NumberRange"] = true,
  2395.         ["Rect"] = true,
  2396.         ["NumberSequence"] = true,
  2397.         ["ColorSequence"] = true,
  2398.         ["Ray"] = true,
  2399.         ["CFrame"] = true
  2400.     }
  2401.  
  2402.     Properties.TypeNameConvert = {
  2403.         ["number"] = "double",
  2404.         ["boolean"] = "bool"
  2405.     }
  2406.  
  2407.     Properties.ToNumberTypes = {
  2408.         ["int"] = true,
  2409.         ["int64"] = true,
  2410.         ["float"] = true,
  2411.         ["double"] = true
  2412.     }
  2413.  
  2414.     Properties.DefaultPropValue = {
  2415.         string = "",
  2416.         bool = false,
  2417.         double = 0,
  2418.         UDim = UDim.new(0,0),
  2419.         UDim2 = UDim2.new(0,0,0,0),
  2420.         BrickColor = BrickColor.new("Medium stone grey"),
  2421.         Color3 = Color3.new(1,1,1),
  2422.         Vector2 = Vector2.new(0,0),
  2423.         Vector3 = Vector3.new(0,0,0),
  2424.         NumberSequence = NumberSequence.new(1),
  2425.         ColorSequence = ColorSequence.new(Color3.new(1,1,1)),
  2426.         NumberRange = NumberRange.new(0),
  2427.         Rect = Rect.new(0,0,0,0)
  2428.     }
  2429.  
  2430.     Properties.AllowedAttributeTypes = {"string","boolean","number","UDim","UDim2","BrickColor","Color3","Vector2","Vector3","NumberSequence","ColorSequence","NumberRange","Rect"}
  2431.  
  2432.     Properties.StringToValue = function(prop,str)
  2433.         local typeData = prop.ValueType
  2434.         local typeName = typeData.Name
  2435.  
  2436.         if typeName == "string" or typeName == "Content" then
  2437.             return str
  2438.         elseif Properties.ToNumberTypes[typeName] then
  2439.             return tonumber(str)
  2440.         elseif typeName == "Vector2" then
  2441.             local vals = str:split(",")
  2442.             local x,y = tonumber(vals[1]),tonumber(vals[2])
  2443.             if x and y and #vals >= 2 then return Vector2.new(x,y) end
  2444.         elseif typeName == "Vector3" then
  2445.             local vals = str:split(",")
  2446.             local x,y,z = tonumber(vals[1]),tonumber(vals[2]),tonumber(vals[3])
  2447.             if x and y and z and #vals >= 3 then return Vector3.new(x,y,z) end
  2448.         elseif typeName == "UDim" then
  2449.             local vals = str:split(",")
  2450.             local scale,offset = tonumber(vals[1]),tonumber(vals[2])
  2451.             if scale and offset and #vals >= 2 then return UDim.new(scale,offset) end
  2452.         elseif typeName == "UDim2" then
  2453.             local vals = str:gsub("[{}]",""):split(",")
  2454.             local xScale,xOffset,yScale,yOffset = tonumber(vals[1]),tonumber(vals[2]),tonumber(vals[3]),tonumber(vals[4])
  2455.             if xScale and xOffset and yScale and yOffset and #vals >= 4 then return UDim2.new(xScale,xOffset,yScale,yOffset) end
  2456.         elseif typeName == "CFrame" then
  2457.             local vals = str:split(",")
  2458.             local s,result = pcall(CFrame.new,unpack(vals))
  2459.             if s and #vals >= 12 then return result end
  2460.         elseif typeName == "Rect" then
  2461.             local vals = str:split(",")
  2462.             local s,result = pcall(Rect.new,unpack(vals))
  2463.             if s and #vals >= 4 then return result end
  2464.         elseif typeName == "Ray" then
  2465.             local vals = str:gsub("[{}]",""):split(",")
  2466.             local s,origin = pcall(Vector3.new,unpack(vals,1,3))
  2467.             local s2,direction = pcall(Vector3.new,unpack(vals,4,6))
  2468.             if s and s2 and #vals >= 6 then return Ray.new(origin,direction) end
  2469.         elseif typeName == "NumberRange" then
  2470.             local vals = str:split(",")
  2471.             local s,result = pcall(NumberRange.new,unpack(vals))
  2472.             if s and #vals >= 1 then return result end
  2473.         elseif typeName == "Color3" then
  2474.             local vals = str:gsub("[{}]",""):split(",")
  2475.             local s,result = pcall(Color3.fromRGB,unpack(vals))
  2476.             if s and #vals >= 3 then return result end
  2477.         end
  2478.  
  2479.         return nil
  2480.     end
  2481.  
  2482.     Properties.ValueToString = function(prop,val)
  2483.         local typeData = prop.ValueType
  2484.         local typeName = typeData.Name
  2485.  
  2486.         if typeName == "Color3" then
  2487.             return Lib.ColorToBytes(val)
  2488.         elseif typeName == "NumberRange" then
  2489.             return val.Min..", "..val.Max
  2490.         end
  2491.  
  2492.         return tostring(val)
  2493.     end
  2494.  
  2495.     Properties.GetIndexableProps = function(obj,classData)
  2496.         if not Main.Elevated then
  2497.             if not pcall(function() return obj.ClassName end) then return nil end
  2498.         end
  2499.  
  2500.         local ignoreProps = Properties.IgnoreProps[classData.Name] or {}
  2501.  
  2502.         local result = {}
  2503.         local count = 1
  2504.         local props = classData.Properties
  2505.         for i = 1,#props do
  2506.             local prop = props[i]
  2507.             if not ignoreProps[prop.Name] then
  2508.                 local s = pcall(function() return obj[prop.Name] end)
  2509.                 if s then
  2510.                     result[count] = prop
  2511.                     count = count + 1
  2512.                 end
  2513.             end
  2514.         end
  2515.  
  2516.         return result
  2517.     end
  2518.  
  2519.     Properties.FindFirstObjWhichIsA = function(class)
  2520.         local classList = Properties.ClassLists[class] or {}
  2521.         if classList and #classList > 0 then
  2522.             return classList[1]
  2523.         end
  2524.  
  2525.         return nil
  2526.     end
  2527.  
  2528.     Properties.ComputeConflicts = function(p)
  2529.         local maxConflictCheck = Settings.Properties.MaxConflictCheck
  2530.         local sList = Explorer.Selection.List
  2531.         local classLists = Properties.ClassLists
  2532.         local stringSplit = string.split
  2533.         local t_clear = table.clear
  2534.         local conflictIgnore = Properties.ConflictIgnore
  2535.         local conflictMap = {}
  2536.         local propList = p and {p} or props
  2537.  
  2538.         if p then
  2539.             local gName = p.Class.."."..p.Name
  2540.             autoUpdateObjs[gName] = nil
  2541.             local subProps = Properties.ConflictSubProps[p.ValueType.Name] or {}
  2542.             for i = 1,#subProps do
  2543.                 autoUpdateObjs[gName.."."..subProps[i]] = nil
  2544.             end
  2545.         else
  2546.             table.clear(autoUpdateObjs)
  2547.         end
  2548.  
  2549.         if #sList > 0 then
  2550.             for i = 1,#propList do
  2551.                 local prop = propList[i]
  2552.                 local propName,propClass = prop.Name,prop.Class
  2553.                 local typeData = prop.RootType or prop.ValueType
  2554.                 local typeName = typeData.Name
  2555.                 local attributeName = prop.AttributeName
  2556.                 local gName = propClass.."."..propName
  2557.  
  2558.                 local checked = 0
  2559.                 local subProps = Properties.ConflictSubProps[typeName] or {}
  2560.                 local subPropCount = #subProps
  2561.                 local toCheck = subPropCount + 1
  2562.                 local conflictsFound = 0
  2563.                 local indexNames = {}
  2564.                 local ignored = conflictIgnore[propClass] and conflictIgnore[propClass][propName]
  2565.                 local truthyCheck = (typeName == "PhysicalProperties")
  2566.                 local isAttribute = prop.IsAttribute
  2567.                 local isMultiType = prop.MultiType
  2568.  
  2569.                 t_clear(conflictMap)
  2570.  
  2571.                 if not isMultiType then
  2572.                     local firstVal,firstObj,firstSet
  2573.                     local classList = classLists[prop.Class] or {}
  2574.                     for c = 1,#classList do
  2575.                         local obj = classList[c]
  2576.                         if not firstSet then
  2577.                             if isAttribute then
  2578.                                 firstVal = getAttribute(obj,attributeName)
  2579.                                 if firstVal ~= nil then
  2580.                                     firstObj = obj
  2581.                                     firstSet = true
  2582.                                 end
  2583.                             else
  2584.                                 firstVal = obj[propName]
  2585.                                 firstObj = obj
  2586.                                 firstSet = true
  2587.                             end
  2588.                             if ignored then break end
  2589.                         else
  2590.                             local propVal,skip
  2591.                             if isAttribute then
  2592.                                 propVal = getAttribute(obj,attributeName)
  2593.                                 if propVal == nil then skip = true end
  2594.                             else
  2595.                                 propVal = obj[propName]
  2596.                             end
  2597.  
  2598.                             if not skip then
  2599.                                 if not conflictMap[1] then
  2600.                                     if truthyCheck then
  2601.                                         if (firstVal and true or false) ~= (propVal and true or false) then
  2602.                                             conflictMap[1] = true
  2603.                                             conflictsFound = conflictsFound + 1
  2604.                                         end
  2605.                                     elseif firstVal ~= propVal then
  2606.                                         conflictMap[1] = true
  2607.                                         conflictsFound = conflictsFound + 1
  2608.                                     end
  2609.                                 end
  2610.  
  2611.                                 if subPropCount > 0 then
  2612.                                     for sPropInd = 1,subPropCount do
  2613.                                         local indexes = indexNames[sPropInd]
  2614.                                         if not indexes then indexes = stringSplit(subProps[sPropInd],".") indexNames[sPropInd] = indexes end
  2615.  
  2616.                                         local firstValSub = firstVal
  2617.                                         local propValSub = propVal
  2618.  
  2619.                                         for j = 1,#indexes do
  2620.                                             if not firstValSub or not propValSub then break end -- PhysicalProperties
  2621.                                             local indexName = indexes[j]
  2622.                                             firstValSub = firstValSub[indexName]
  2623.                                             propValSub = propValSub[indexName]
  2624.                                         end
  2625.  
  2626.                                         local mapInd = sPropInd + 1
  2627.                                         if not conflictMap[mapInd] and firstValSub ~= propValSub then
  2628.                                             conflictMap[mapInd] = true
  2629.                                             conflictsFound = conflictsFound + 1
  2630.                                         end
  2631.                                     end
  2632.                                 end
  2633.  
  2634.                                 if conflictsFound == toCheck then break end
  2635.                             end
  2636.                         end
  2637.  
  2638.                         checked = checked + 1
  2639.                         if checked == maxConflictCheck then break end
  2640.                     end
  2641.  
  2642.                     if not conflictMap[1] then autoUpdateObjs[gName] = firstObj end
  2643.                     for sPropInd = 1,subPropCount do
  2644.                         if not conflictMap[sPropInd+1] then
  2645.                             autoUpdateObjs[gName.."."..subProps[sPropInd]] = firstObj
  2646.                         end
  2647.                     end
  2648.                 end
  2649.             end
  2650.         end
  2651.  
  2652.         if p then
  2653.             Properties.Refresh()
  2654.         end
  2655.     end
  2656.  
  2657.     -- Fetches the properties to be displayed based on the explorer selection
  2658.     Settings.Properties.ShowAttributes = true -- im making it true anyway since its useful by default and people complain
  2659.     Properties.ShowExplorerProps = function()
  2660.         local maxConflictCheck = Settings.Properties.MaxConflictCheck
  2661.         local sList = Explorer.Selection.List
  2662.         local foundClasses = {}
  2663.         local propCount = 1
  2664.         local elevated = Main.Elevated
  2665.         local showDeprecated,showHidden = Settings.Properties.ShowDeprecated,Settings.Properties.ShowHidden
  2666.         local Classes = API.Classes
  2667.         local classLists = {}
  2668.         local lower = string.lower
  2669.         local RMDCustomOrders = RMD.PropertyOrders
  2670.         local getAttributes = game["Run Service"].Parent.GetAttributes
  2671.         local maxAttrs = Settings.Properties.MaxAttributes
  2672.         local showingAttrs = Settings.Properties.ShowAttributes
  2673.         local foundAttrs = {}
  2674.         local attrCount = 0
  2675.         local typeof = typeof
  2676.         local typeNameConvert = Properties.TypeNameConvert
  2677.  
  2678.         table.clear(props)
  2679.  
  2680.         for i = 1,#sList do
  2681.             local node = sList[i]
  2682.             local obj = node.Obj
  2683.             local class = node.Class
  2684.             if not class then class = obj.ClassName node.Class = class end
  2685.  
  2686.             local apiClass = Classes[class]
  2687.             while apiClass do
  2688.                 local APIClassName = apiClass.Name
  2689.                 if not foundClasses[APIClassName] then
  2690.                     local apiProps = indexableProps[APIClassName]
  2691.                     if not apiProps then apiProps = Properties.GetIndexableProps(obj,apiClass) indexableProps[APIClassName] = apiProps end
  2692.  
  2693.                     for i = 1,#apiProps do
  2694.                         local prop = apiProps[i]
  2695.                         local tags = prop.Tags
  2696.                         if (not tags.Deprecated or showDeprecated) and (not tags.Hidden or showHidden) then
  2697.                             props[propCount] = prop
  2698.                             propCount = propCount + 1
  2699.                         end
  2700.                     end
  2701.                     foundClasses[APIClassName] = true
  2702.                 end
  2703.  
  2704.                 local classList = classLists[APIClassName]
  2705.                 if not classList then classList = {} classLists[APIClassName] = classList end
  2706.                 classList[#classList+1] = obj
  2707.  
  2708.                 apiClass = apiClass.Superclass
  2709.             end
  2710.  
  2711.             if showingAttrs and attrCount < maxAttrs then
  2712.                 local attrs = getAttributes(obj)
  2713.                 for name,val in pairs(attrs) do
  2714.                     local typ = typeof(val)
  2715.                     if not foundAttrs[name] then
  2716.                         local category = (typ == "Instance" and "Class") or (typ == "EnumItem" and "Enum") or "Other"
  2717.                         local valType = {Name = typeNameConvert[typ] or typ, Category = category}
  2718.                         local attrProp = {IsAttribute = true, Name = "ATTR_"..name, AttributeName = name, DisplayName = name, Class = "Instance", ValueType = valType, Category = "Attributes", Tags = {}}
  2719.                         props[propCount] = attrProp
  2720.                         propCount = propCount + 1
  2721.                         attrCount = attrCount + 1
  2722.                         foundAttrs[name] = {typ,attrProp}
  2723.                         if attrCount == maxAttrs then break end
  2724.                     elseif foundAttrs[name][1] ~= typ then
  2725.                         foundAttrs[name][2].MultiType = true
  2726.                         foundAttrs[name][2].Tags.ReadOnly = true
  2727.                         foundAttrs[name][2].ValueType = {Name = "string"}
  2728.                     end
  2729.                 end
  2730.             end
  2731.         end
  2732.  
  2733.         table.sort(props,function(a,b)
  2734.             if a.Category ~= b.Category then
  2735.                 return (categoryOrder[a.Category] or 9999) < (categoryOrder[b.Category] or 9999)
  2736.             else
  2737.                 local aOrder = (RMDCustomOrders[a.Class] and RMDCustomOrders[a.Class][a.Name]) or 9999999
  2738.                 local bOrder = (RMDCustomOrders[b.Class] and RMDCustomOrders[b.Class][b.Name]) or 9999999
  2739.                 if aOrder ~= bOrder then
  2740.                     return aOrder < bOrder
  2741.                 else
  2742.                     return lower(a.Name) < lower(b.Name)
  2743.                 end
  2744.             end
  2745.         end)
  2746.  
  2747.         -- Find conflicts and get auto-update instances
  2748.         Properties.ClassLists = classLists
  2749.         Properties.ComputeConflicts()
  2750.         --warn("CONFLICT",tick()-start)
  2751.         if #props > 0 then
  2752.             props[#props+1] = Properties.AddAttributeProp
  2753.         end
  2754.  
  2755.         Properties.Update()
  2756.         Properties.Refresh()
  2757.     end
  2758.  
  2759.     Properties.UpdateView = function()
  2760.         local maxEntries = math.ceil(propsFrame.AbsoluteSize.Y / 23)
  2761.         local maxX = propsFrame.AbsoluteSize.X
  2762.         local totalWidth = Properties.ViewWidth + Properties.MinInputWidth
  2763.  
  2764.         scrollV.VisibleSpace = maxEntries
  2765.         scrollV.TotalSpace = #viewList + 1
  2766.         scrollH.VisibleSpace = maxX
  2767.         scrollH.TotalSpace = totalWidth
  2768.  
  2769.         scrollV.Gui.Visible = #viewList + 1 > maxEntries
  2770.         scrollH.Gui.Visible = Settings.Properties.ScaleType == 0 and totalWidth > maxX
  2771.  
  2772.         local oldSize = propsFrame.Size
  2773.         propsFrame.Size = UDim2.new(1,(scrollV.Gui.Visible and -16 or 0),1,(scrollH.Gui.Visible and -39 or -23))
  2774.         if oldSize ~= propsFrame.Size then
  2775.             Properties.UpdateView()
  2776.         else
  2777.             scrollV:Update()
  2778.             scrollH:Update()
  2779.  
  2780.             if scrollV.Gui.Visible and scrollH.Gui.Visible then
  2781.                 scrollV.Gui.Size = UDim2.new(0,16,1,-39)
  2782.                 scrollH.Gui.Size = UDim2.new(1,-16,0,16)
  2783.                 Properties.Window.GuiElems.Content.ScrollCorner.Visible = true
  2784.             else
  2785.                 scrollV.Gui.Size = UDim2.new(0,16,1,-23)
  2786.                 scrollH.Gui.Size = UDim2.new(1,0,0,16)
  2787.                 Properties.Window.GuiElems.Content.ScrollCorner.Visible = false
  2788.             end
  2789.  
  2790.             Properties.Index = scrollV.Index
  2791.         end
  2792.     end
  2793.  
  2794.     Properties.MakeSubProp = function(prop,subName,valueType,displayName)
  2795.         local subProp = {}
  2796.         for i,v in pairs(prop) do
  2797.             subProp[i] = v
  2798.         end
  2799.         subProp.RootType = subProp.RootType or subProp.ValueType
  2800.         subProp.ValueType = valueType
  2801.         subProp.SubName = subProp.SubName and (subProp.SubName..subName) or subName
  2802.         subProp.DisplayName = displayName
  2803.  
  2804.         return subProp
  2805.     end
  2806.  
  2807.     Properties.GetExpandedProps = function(prop) -- TODO: Optimize using table
  2808.         local result = {}
  2809.         local typeData = prop.ValueType
  2810.         local typeName = typeData.Name
  2811.         local makeSubProp = Properties.MakeSubProp
  2812.  
  2813.         if typeName == "Vector2" then
  2814.             result[1] = makeSubProp(prop,".X",{Name = "float"})
  2815.             result[2] = makeSubProp(prop,".Y",{Name = "float"})
  2816.         elseif typeName == "Vector3" then
  2817.             result[1] = makeSubProp(prop,".X",{Name = "float"})
  2818.             result[2] = makeSubProp(prop,".Y",{Name = "float"})
  2819.             result[3] = makeSubProp(prop,".Z",{Name = "float"})
  2820.         elseif typeName == "CFrame" then
  2821.             result[1] = makeSubProp(prop,".Position",{Name = "Vector3"})
  2822.             result[2] = makeSubProp(prop,".RightVector",{Name = "Vector3"})
  2823.             result[3] = makeSubProp(prop,".UpVector",{Name = "Vector3"})
  2824.             result[4] = makeSubProp(prop,".LookVector",{Name = "Vector3"})
  2825.         elseif typeName == "UDim" then
  2826.             result[1] = makeSubProp(prop,".Scale",{Name = "float"})
  2827.             result[2] = makeSubProp(prop,".Offset",{Name = "int"})
  2828.         elseif typeName == "UDim2" then
  2829.             result[1] = makeSubProp(prop,".X",{Name = "UDim"})
  2830.             result[2] = makeSubProp(prop,".Y",{Name = "UDim"})
  2831.         elseif typeName == "Rect" then
  2832.             result[1] = makeSubProp(prop,".Min.X",{Name = "float"},"X0")
  2833.             result[2] = makeSubProp(prop,".Min.Y",{Name = "float"},"Y0")
  2834.             result[3] = makeSubProp(prop,".Max.X",{Name = "float"},"X1")
  2835.             result[4] = makeSubProp(prop,".Max.Y",{Name = "float"},"Y1")
  2836.         elseif typeName == "PhysicalProperties" then
  2837.             result[1] = makeSubProp(prop,".Density",{Name = "float"})
  2838.             result[2] = makeSubProp(prop,".Elasticity",{Name = "float"})
  2839.             result[3] = makeSubProp(prop,".ElasticityWeight",{Name = "float"})
  2840.             result[4] = makeSubProp(prop,".Friction",{Name = "float"})
  2841.             result[5] = makeSubProp(prop,".FrictionWeight",{Name = "float"})
  2842.         elseif typeName == "Ray" then
  2843.             result[1] = makeSubProp(prop,".Origin",{Name = "Vector3"})
  2844.             result[2] = makeSubProp(prop,".Direction",{Name = "Vector3"})
  2845.         elseif typeName == "NumberRange" then
  2846.             result[1] = makeSubProp(prop,".Min",{Name = "float"})
  2847.             result[2] = makeSubProp(prop,".Max",{Name = "float"})
  2848.         elseif typeName == "Faces" then
  2849.             result[1] = makeSubProp(prop,".Back",{Name = "bool"})
  2850.             result[2] = makeSubProp(prop,".Bottom",{Name = "bool"})
  2851.             result[3] = makeSubProp(prop,".Front",{Name = "bool"})
  2852.             result[4] = makeSubProp(prop,".Left",{Name = "bool"})
  2853.             result[5] = makeSubProp(prop,".Right",{Name = "bool"})
  2854.             result[6] = makeSubProp(prop,".Top",{Name = "bool"})
  2855.         elseif typeName == "Axes" then
  2856.             result[1] = makeSubProp(prop,".X",{Name = "bool"})
  2857.             result[2] = makeSubProp(prop,".Y",{Name = "bool"})
  2858.             result[3] = makeSubProp(prop,".Z",{Name = "bool"})
  2859.         end
  2860.  
  2861.         if prop.Name == "SoundId" and prop.Class == "Sound" then
  2862.             result[1] = Properties.SoundPreviewProp
  2863.         end
  2864.  
  2865.         return result
  2866.     end
  2867.  
  2868.     Properties.Update = function()
  2869.         table.clear(viewList)
  2870.  
  2871.         local nameWidthCache = Properties.NameWidthCache
  2872.         local lastCategory
  2873.         local count = 1
  2874.         local maxWidth,maxDepth = 0,1
  2875.  
  2876.         local textServ = service.TextService
  2877.         local getTextSize = textServ.GetTextSize
  2878.         local font = Enum.Font.SourceSans
  2879.         local size = Vector2.new(math.huge,20)
  2880.         local stringSplit = string.split
  2881.         local entryIndent = Properties.EntryIndent
  2882.         local isFirstScaleType = Settings.Properties.ScaleType == 0
  2883.         local find,lower = string.find,string.lower
  2884.         local searchText = (#Properties.SearchText > 0 and lower(Properties.SearchText))
  2885.  
  2886.         local function recur(props,depth)
  2887.             for i = 1,#props do
  2888.                 local prop = props[i]
  2889.                 local propName = prop.Name
  2890.                 local subName = prop.SubName
  2891.                 local category = prop.Category
  2892.  
  2893.                 local visible
  2894.                 if searchText and depth == 1 then
  2895.                     if find(lower(propName),searchText,1,true) then
  2896.                         visible = true
  2897.                     end
  2898.                 else
  2899.                     visible = true
  2900.                 end
  2901.  
  2902.                 if visible and lastCategory ~= category then
  2903.                     viewList[count] = {CategoryName = category}
  2904.                     count = count + 1
  2905.                     lastCategory = category
  2906.                 end
  2907.  
  2908.                 if (expanded["CAT_"..category] and visible) or prop.SpecialRow then
  2909.                     if depth > 1 then prop.Depth = depth if depth > maxDepth then maxDepth = depth end end
  2910.  
  2911.                     if isFirstScaleType then
  2912.                         local nameArr = subName and stringSplit(subName,".")
  2913.                         local displayName = prop.DisplayName or (nameArr and nameArr[#nameArr]) or propName
  2914.  
  2915.                         local nameWidth = nameWidthCache[displayName]
  2916.                         if not nameWidth then nameWidth = getTextSize(textServ,displayName,14,font,size).X nameWidthCache[displayName] = nameWidth end
  2917.  
  2918.                         local totalWidth = nameWidth + entryIndent*depth
  2919.                         if totalWidth > maxWidth then
  2920.                             maxWidth = totalWidth
  2921.                         end
  2922.                     end
  2923.  
  2924.                     viewList[count] = prop
  2925.                     count = count + 1
  2926.  
  2927.                     local fullName = prop.Class.."."..prop.Name..(prop.SubName or "")
  2928.                     if expanded[fullName] then
  2929.                         local nextDepth = depth+1
  2930.                         local expandedProps = Properties.GetExpandedProps(prop)
  2931.                         if #expandedProps > 0 then
  2932.                             recur(expandedProps,nextDepth)
  2933.                         end
  2934.                     end
  2935.                 end
  2936.             end
  2937.         end
  2938.         recur(props,1)
  2939.  
  2940.         inputProp = nil
  2941.         Properties.ViewWidth = maxWidth + 9 + Properties.EntryOffset
  2942.         Properties.UpdateView()
  2943.     end
  2944.  
  2945.     Properties.NewPropEntry = function(index)
  2946.         local newEntry = Properties.EntryTemplate:Clone()
  2947.         local nameFrame = newEntry.NameFrame
  2948.         local valueFrame = newEntry.ValueFrame
  2949.         local newCheckbox = Lib.Checkbox.new(1)
  2950.         newCheckbox.Gui.Position = UDim2.new(0,3,0,3)
  2951.         newCheckbox.Gui.Parent = valueFrame
  2952.         newCheckbox.OnInput:Connect(function()
  2953.             local prop = viewList[index + Properties.Index]
  2954.             if not prop then return end
  2955.  
  2956.             if prop.ValueType.Name == "PhysicalProperties" then
  2957.                 Properties.SetProp(prop,newCheckbox.Toggled and true or nil)
  2958.             else
  2959.                 Properties.SetProp(prop,newCheckbox.Toggled)
  2960.             end
  2961.         end)
  2962.         checkboxes[index] = newCheckbox
  2963.  
  2964.         local iconFrame = Main.MiscIcons:GetLabel()
  2965.         iconFrame.Position = UDim2.new(0,2,0,3)
  2966.         iconFrame.Parent = newEntry.ValueFrame.RightButton
  2967.  
  2968.         newEntry.Position = UDim2.new(0,0,0,23*(index-1))
  2969.  
  2970.         nameFrame.Expand.InputBegan:Connect(function(input)
  2971.             local prop = viewList[index + Properties.Index]
  2972.             if not prop or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  2973.  
  2974.             local fullName = (prop.CategoryName and "CAT_"..prop.CategoryName) or prop.Class.."."..prop.Name..(prop.SubName or "")
  2975.  
  2976.             Main.MiscIcons:DisplayByKey(newEntry.NameFrame.Expand.Icon, expanded[fullName] and "Collapse_Over" or "Expand_Over")
  2977.         end)
  2978.  
  2979.         nameFrame.Expand.InputEnded:Connect(function(input)
  2980.             local prop = viewList[index + Properties.Index]
  2981.             if not prop or input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
  2982.  
  2983.             local fullName = (prop.CategoryName and "CAT_"..prop.CategoryName) or prop.Class.."."..prop.Name..(prop.SubName or "")
  2984.  
  2985.             Main.MiscIcons:DisplayByKey(newEntry.NameFrame.Expand.Icon, expanded[fullName] and "Collapse" or "Expand")
  2986.         end)
  2987.  
  2988.         nameFrame.Expand.MouseButton1Down:Connect(function()
  2989.             local prop = viewList[index + Properties.Index]
  2990.             if not prop then return end
  2991.  
  2992.             local fullName = (prop.CategoryName and "CAT_"..prop.CategoryName) or prop.Class.."."..prop.Name..(prop.SubName or "")
  2993.             if not prop.CategoryName and not Properties.ExpandableTypes[prop.ValueType and prop.ValueType.Name] and not Properties.ExpandableProps[fullName] then return end
  2994.  
  2995.             expanded[fullName] = not expanded[fullName]
  2996.             Properties.Update()
  2997.             Properties.Refresh()
  2998.         end)
  2999.  
  3000.         nameFrame.PropName.InputBegan:Connect(function(input)
  3001.             local prop = viewList[index + Properties.Index]
  3002.             if not prop then return end
  3003.             if input.UserInputType == Enum.UserInputType.MouseMovement and not nameFrame.PropName.TextFits then
  3004.                 local fullNameFrame = Properties.FullNameFrame 
  3005.                 local nameArr = string.split(prop.Class.."."..prop.Name..(prop.SubName or ""),".")
  3006.                 local dispName = prop.DisplayName or nameArr[#nameArr]
  3007.                 local sizeX = service.TextService:GetTextSize(dispName,14,Enum.Font.SourceSans,Vector2.new(math.huge,20)).X
  3008.  
  3009.                 fullNameFrame.TextLabel.Text = dispName
  3010.                 --fullNameFrame.Position = UDim2.new(0,Properties.EntryIndent*(prop.Depth or 1) + Properties.EntryOffset,0,23*(index-1))
  3011.                 fullNameFrame.Size = UDim2.new(0,sizeX + 4,0,22)
  3012.                 fullNameFrame.Visible = true
  3013.                 Properties.FullNameFrameIndex = index
  3014.                 Properties.FullNameFrameAttach.SetData(fullNameFrame, {Target = nameFrame})
  3015.                 Properties.FullNameFrameAttach.Enable()
  3016.             end
  3017.         end)
  3018.  
  3019.         nameFrame.PropName.InputEnded:Connect(function(input)
  3020.             if input.UserInputType == Enum.UserInputType.MouseMovement and Properties.FullNameFrameIndex == index then
  3021.                 Properties.FullNameFrame.Visible = false
  3022.                 Properties.FullNameFrameAttach.Disable()
  3023.             end
  3024.         end)
  3025.  
  3026.         valueFrame.ValueBox.MouseButton1Down:Connect(function()
  3027.             local prop = viewList[index + Properties.Index]
  3028.             if not prop then return end
  3029.  
  3030.             Properties.SetInputProp(prop,index)
  3031.         end)
  3032.  
  3033.         valueFrame.ColorButton.MouseButton1Down:Connect(function()
  3034.             local prop = viewList[index + Properties.Index]
  3035.             if not prop then return end
  3036.  
  3037.             Properties.SetInputProp(prop,index,"color")
  3038.         end)
  3039.  
  3040.         valueFrame.RightButton.MouseButton1Click:Connect(function()
  3041.             local prop = viewList[index + Properties.Index]
  3042.             if not prop then return end
  3043.  
  3044.             local fullName = prop.Class.."."..prop.Name..(prop.SubName or "")
  3045.             local inputFullName = inputProp and (inputProp.Class.."."..inputProp.Name..(inputProp.SubName or ""))
  3046.  
  3047.             if fullName == inputFullName and inputProp.ValueType.Category == "Class" then
  3048.                 inputProp = nil
  3049.                 Properties.SetProp(prop,nil)
  3050.             else
  3051.                 Properties.SetInputProp(prop,index,"right")
  3052.             end
  3053.         end)
  3054.  
  3055.         nameFrame.ToggleAttributes.MouseButton1Click:Connect(function()
  3056.             Settings.Properties.ShowAttributes = not Settings.Properties.ShowAttributes
  3057.             Properties.ShowExplorerProps()
  3058.         end)
  3059.  
  3060.         newEntry.RowButton.MouseButton1Click:Connect(function()
  3061.             Properties.DisplayAddAttributeWindow()
  3062.         end)
  3063.  
  3064.         newEntry.EditAttributeButton.MouseButton1Down:Connect(function()
  3065.             local prop = viewList[index + Properties.Index]
  3066.             if not prop then return end
  3067.  
  3068.             Properties.DisplayAttributeContext(prop)
  3069.         end)
  3070.  
  3071.         valueFrame.SoundPreview.ControlButton.MouseButton1Click:Connect(function()
  3072.             if Properties.PreviewSound and Properties.PreviewSound.Playing then
  3073.                 Properties.SetSoundPreview(false)
  3074.             else
  3075.                 local soundObj = Properties.FindFirstObjWhichIsA("Sound")
  3076.                 if soundObj then Properties.SetSoundPreview(soundObj) end
  3077.             end
  3078.         end)
  3079.  
  3080.         valueFrame.SoundPreview.InputBegan:Connect(function(input)
  3081.             if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  3082.  
  3083.             local releaseEvent,mouseEvent
  3084.             releaseEvent = service.UserInputService.InputEnded:Connect(function(input)
  3085.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  3086.                 releaseEvent:Disconnect()
  3087.                 mouseEvent:Disconnect()
  3088.             end)
  3089.  
  3090.             local timeLine = newEntry.ValueFrame.SoundPreview.TimeLine
  3091.             local soundObj = Properties.FindFirstObjWhichIsA("Sound")
  3092.             if soundObj then Properties.SetSoundPreview(soundObj,true) end
  3093.  
  3094.             local function update(input)
  3095.                 local sound = Properties.PreviewSound
  3096.                 if not sound or sound.TimeLength == 0 then return end
  3097.  
  3098.                 local mouseX = input.Position.X
  3099.                 local timeLineSize = timeLine.AbsoluteSize
  3100.                 local relaX = mouseX - timeLine.AbsolutePosition.X
  3101.  
  3102.                 if timeLineSize.X <= 1 then return end
  3103.                 if relaX < 0 then relaX = 0 elseif relaX >= timeLineSize.X then relaX = timeLineSize.X-1 end
  3104.  
  3105.                 local perc = (relaX/(timeLineSize.X-1))
  3106.                 sound.TimePosition = perc*sound.TimeLength
  3107.                 timeLine.Slider.Position = UDim2.new(perc,-4,0,-8)
  3108.             end
  3109.             update(input)
  3110.  
  3111.             mouseEvent = service.UserInputService.InputChanged:Connect(function(input)
  3112.                 if input.UserInputType == Enum.UserInputType.MouseMovement then
  3113.                     update(input)
  3114.                 end
  3115.             end)
  3116.         end)
  3117.  
  3118.         newEntry.Parent = propsFrame
  3119.  
  3120.         return {
  3121.             Gui = newEntry,
  3122.             GuiElems = {
  3123.                 NameFrame = nameFrame,
  3124.                 ValueFrame = valueFrame,
  3125.                 PropName = nameFrame.PropName,
  3126.                 ValueBox = valueFrame.ValueBox,
  3127.                 Expand = nameFrame.Expand,
  3128.                 ColorButton = valueFrame.ColorButton,
  3129.                 ColorPreview = valueFrame.ColorButton.ColorPreview,
  3130.                 Gradient = valueFrame.ColorButton.ColorPreview.UIGradient,
  3131.                 EnumArrow = valueFrame.EnumArrow,
  3132.                 Checkbox = valueFrame.Checkbox,
  3133.                 RightButton = valueFrame.RightButton,
  3134.                 RightButtonIcon = iconFrame,
  3135.                 RowButton = newEntry.RowButton,
  3136.                 EditAttributeButton = newEntry.EditAttributeButton,
  3137.                 ToggleAttributes = nameFrame.ToggleAttributes,
  3138.                 SoundPreview = valueFrame.SoundPreview,
  3139.                 SoundPreviewSlider = valueFrame.SoundPreview.TimeLine.Slider
  3140.             }
  3141.         }
  3142.     end
  3143.  
  3144.     Properties.GetSoundPreviewEntry = function()
  3145.         for i = 1,#viewList do
  3146.             if viewList[i] == Properties.SoundPreviewProp then
  3147.                 return propEntries[i - Properties.Index]
  3148.             end
  3149.         end
  3150.     end
  3151.  
  3152.     Properties.SetSoundPreview = function(soundObj,noplay)
  3153.         local sound = Properties.PreviewSound
  3154.         if not sound then
  3155.             sound = Instance.new("Sound")
  3156.             sound.Name = "Preview"
  3157.             sound.Paused:Connect(function()
  3158.                 local entry = Properties.GetSoundPreviewEntry()
  3159.                 if entry then Main.MiscIcons:DisplayByKey(entry.GuiElems.SoundPreview.ControlButton.Icon, "Play") end
  3160.             end)
  3161.             sound.Resumed:Connect(function() Properties.Refresh() end)
  3162.             sound.Ended:Connect(function()
  3163.                 local entry = Properties.GetSoundPreviewEntry()
  3164.                 if entry then entry.GuiElems.SoundPreviewSlider.Position = UDim2.new(0,-4,0,-8) end
  3165.                 Properties.Refresh()
  3166.             end)
  3167.             sound.Parent = window.Gui
  3168.             Properties.PreviewSound = sound
  3169.         end
  3170.  
  3171.         if not soundObj then
  3172.             sound:Pause()
  3173.         else
  3174.             local newId = sound.SoundId ~= soundObj.SoundId
  3175.             sound.SoundId = soundObj.SoundId
  3176.             sound.PlaybackSpeed = soundObj.PlaybackSpeed
  3177.             sound.Volume = soundObj.Volume
  3178.             if newId then sound.TimePosition = 0 end
  3179.             if not noplay then sound:Resume() end
  3180.  
  3181.             coroutine.wrap(function()
  3182.                 local previewTime = tick()
  3183.                 Properties.SoundPreviewTime = previewTime
  3184.                 while previewTime == Properties.SoundPreviewTime and sound.Playing do
  3185.                     local entry = Properties.GetSoundPreviewEntry()
  3186.                     if entry then
  3187.                         local tl = sound.TimeLength
  3188.                         local perc = sound.TimePosition/(tl == 0 and 1 or tl)
  3189.                         entry.GuiElems.SoundPreviewSlider.Position = UDim2.new(perc,-4,0,-8)
  3190.                     end
  3191.                     Lib.FastWait()
  3192.                 end
  3193.             end)()
  3194.             Properties.Refresh()
  3195.         end
  3196.     end
  3197.  
  3198.     Properties.DisplayAttributeContext = function(prop)
  3199.         local context = Properties.AttributeContext
  3200.         if not context then
  3201.             context = Lib.ContextMenu.new()
  3202.             context.Iconless = true
  3203.             context.Width = 80
  3204.         end
  3205.         context:Clear()
  3206.  
  3207.         context:Add({Name = "Edit", OnClick = function()
  3208.             Properties.DisplayAddAttributeWindow(prop)
  3209.         end})
  3210.         context:Add({Name = "Delete", OnClick = function()
  3211.             Properties.SetProp(prop,nil,true)
  3212.             Properties.ShowExplorerProps()
  3213.         end})
  3214.  
  3215.         context:Show()
  3216.     end
  3217.  
  3218.     Properties.DisplayAddAttributeWindow = function(editAttr)
  3219.         local win = Properties.AddAttributeWindow
  3220.         if not win then
  3221.             win = Lib.Window.new()
  3222.             win.Alignable = false
  3223.             win.Resizable = false
  3224.             win:SetTitle("Add Attribute")
  3225.             win:SetSize(200,130)
  3226.  
  3227.             local saveButton = Lib.Button.new()
  3228.             local nameLabel = Lib.Label.new()
  3229.             nameLabel.Text = "Name"
  3230.             nameLabel.Position = UDim2.new(0,30,0,10)
  3231.             nameLabel.Size = UDim2.new(0,40,0,20)
  3232.             win:Add(nameLabel)
  3233.  
  3234.             local nameBox = Lib.ViewportTextBox.new()
  3235.             nameBox.Position = UDim2.new(0,75,0,10)
  3236.             nameBox.Size = UDim2.new(0,120,0,20)
  3237.             win:Add(nameBox,"NameBox")
  3238.             nameBox.TextBox:GetPropertyChangedSignal("Text"):Connect(function()
  3239.                 saveButton:SetDisabled(#nameBox:GetText() == 0)
  3240.             end)
  3241.  
  3242.             local typeLabel = Lib.Label.new()
  3243.             typeLabel.Text = "Type"
  3244.             typeLabel.Position = UDim2.new(0,30,0,40)
  3245.             typeLabel.Size = UDim2.new(0,40,0,20)
  3246.             win:Add(typeLabel)
  3247.  
  3248.             local typeChooser = Lib.DropDown.new()
  3249.             typeChooser.CanBeEmpty = false
  3250.             typeChooser.Position = UDim2.new(0,75,0,40)
  3251.             typeChooser.Size = UDim2.new(0,120,0,20)
  3252.             typeChooser:SetOptions(Properties.AllowedAttributeTypes)
  3253.             win:Add(typeChooser,"TypeChooser")
  3254.  
  3255.             local errorLabel = Lib.Label.new()
  3256.             errorLabel.Text = ""
  3257.             errorLabel.Position = UDim2.new(0,5,1,-45)
  3258.             errorLabel.Size = UDim2.new(1,-10,0,20)
  3259.             errorLabel.TextColor3 = Settings.Theme.Important
  3260.             win.ErrorLabel = errorLabel
  3261.             win:Add(errorLabel,"Error")
  3262.  
  3263.             local cancelButton = Lib.Button.new()
  3264.             cancelButton.Text = "Cancel"
  3265.             cancelButton.Position = UDim2.new(1,-97,1,-25)
  3266.             cancelButton.Size = UDim2.new(0,92,0,20)
  3267.             cancelButton.OnClick:Connect(function()
  3268.                 win:Close()
  3269.             end)
  3270.             win:Add(cancelButton)
  3271.  
  3272.             saveButton.Text = "Save"
  3273.             saveButton.Position = UDim2.new(0,5,1,-25)
  3274.             saveButton.Size = UDim2.new(0,92,0,20)
  3275.             saveButton.OnClick:Connect(function()
  3276.                 local name = nameBox:GetText()
  3277.                 if #name > 100 then
  3278.                     errorLabel.Text = "Error: Name over 100 chars"
  3279.                     return
  3280.                 elseif name:sub(1,3) == "RBX" then
  3281.                     errorLabel.Text = "Error: Name begins with 'RBX'"
  3282.                     return
  3283.                 end
  3284.  
  3285.                 local typ = typeChooser.Selected
  3286.                 local valType = {Name = Properties.TypeNameConvert[typ] or typ, Category = "DataType"}
  3287.                 local attrProp = {IsAttribute = true, Name = "ATTR_"..name, AttributeName = name, DisplayName = name, Class = "Instance", ValueType = valType, Category = "Attributes", Tags = {}}
  3288.  
  3289.                 Settings.Properties.ShowAttributes = true
  3290.                 Properties.SetProp(attrProp,Properties.DefaultPropValue[valType.Name],true,Properties.EditingAttribute)
  3291.                 Properties.ShowExplorerProps()
  3292.                 win:Close()
  3293.             end)
  3294.             win:Add(saveButton,"SaveButton")
  3295.  
  3296.             Properties.AddAttributeWindow = win
  3297.         end
  3298.  
  3299.         Properties.EditingAttribute = editAttr
  3300.         win:SetTitle(editAttr and "Edit Attribute "..editAttr.AttributeName or "Add Attribute")
  3301.         win.Elements.Error.Text = ""
  3302.         win.Elements.NameBox:SetText("")
  3303.         win.Elements.SaveButton:SetDisabled(true)
  3304.         win.Elements.TypeChooser:SetSelected(1)
  3305.         win:Show()
  3306.     end
  3307.  
  3308.     Properties.IsTextEditable = function(prop)
  3309.         local typeData = prop.ValueType
  3310.         local typeName = typeData.Name
  3311.  
  3312.         return typeName ~= "bool" and typeData.Category ~= "Enum" and typeData.Category ~= "Class" and typeName ~= "BrickColor"
  3313.     end
  3314.  
  3315.     Properties.DisplayEnumDropdown = function(entryIndex)
  3316.         local context = Properties.EnumContext
  3317.         if not context then
  3318.             context = Lib.ContextMenu.new()
  3319.             context.Iconless = true
  3320.             context.MaxHeight = 200
  3321.             context.ReverseYOffset = 22
  3322.             Properties.EnumDropdown = context
  3323.         end
  3324.  
  3325.         if not inputProp or inputProp.ValueType.Category ~= "Enum" then return end
  3326.         local prop = inputProp
  3327.  
  3328.         local entry = propEntries[entryIndex]
  3329.         local valueFrame = entry.GuiElems.ValueFrame
  3330.  
  3331.         local enum = Enum[prop.ValueType.Name]
  3332.         if not enum then return end
  3333.  
  3334.         local sorted = {}
  3335.         for name,enum in next,enum:GetEnumItems() do
  3336.             sorted[#sorted+1] = enum
  3337.         end
  3338.         table.sort(sorted,function(a,b) return a.Name < b.Name end)
  3339.  
  3340.         context:Clear()
  3341.  
  3342.         local function onClick(name)
  3343.             if prop ~= inputProp then return end
  3344.  
  3345.             local enumItem = enum[name]
  3346.             inputProp = nil
  3347.             Properties.SetProp(prop,enumItem)
  3348.         end
  3349.  
  3350.         for i = 1,#sorted do
  3351.             local enumItem = sorted[i]
  3352.             context:Add({Name = enumItem.Name, OnClick = onClick})
  3353.         end
  3354.  
  3355.         context.Width = valueFrame.AbsoluteSize.X
  3356.         context:Show(valueFrame.AbsolutePosition.X, valueFrame.AbsolutePosition.Y + 22)
  3357.     end
  3358.  
  3359.     Properties.DisplayBrickColorEditor = function(prop,entryIndex,col)
  3360.         local editor = Properties.BrickColorEditor
  3361.         if not editor then
  3362.             editor = Lib.BrickColorPicker.new()
  3363.             editor.Gui.DisplayOrder = Main.DisplayOrders.Menu
  3364.             editor.ReverseYOffset = 22
  3365.  
  3366.             editor.OnSelect:Connect(function(col)
  3367.                 if not editor.CurrentProp or editor.CurrentProp.ValueType.Name ~= "BrickColor" then return end
  3368.  
  3369.                 if editor.CurrentProp == inputProp then inputProp = nil end
  3370.                 Properties.SetProp(editor.CurrentProp,BrickColor.new(col))
  3371.             end)
  3372.  
  3373.             editor.OnMoreColors:Connect(function() -- TODO: Special Case BasePart.BrickColor to BasePart.Color
  3374.                 editor:Close()
  3375.                 local colProp
  3376.                 for i,v in pairs(API.Classes.BasePart.Properties) do
  3377.                     if v.Name == "Color" then
  3378.                         colProp = v
  3379.                         break
  3380.                     end
  3381.                 end
  3382.                 Properties.DisplayColorEditor(colProp,editor.SavedColor.Color)
  3383.             end)
  3384.  
  3385.             Properties.BrickColorEditor = editor
  3386.         end
  3387.  
  3388.         local entry = propEntries[entryIndex]
  3389.         local valueFrame = entry.GuiElems.ValueFrame
  3390.  
  3391.         editor.CurrentProp = prop
  3392.         editor.SavedColor = col
  3393.         if prop and prop.Class == "BasePart" and prop.Name == "BrickColor" then
  3394.             editor:SetMoreColorsVisible(true)
  3395.         else
  3396.             editor:SetMoreColorsVisible(false)
  3397.         end
  3398.         editor:Show(valueFrame.AbsolutePosition.X, valueFrame.AbsolutePosition.Y + 22)
  3399.     end
  3400.  
  3401.     Properties.DisplayColorEditor = function(prop,col)
  3402.         local editor = Properties.ColorEditor
  3403.         if not editor then
  3404.             editor = Lib.ColorPicker.new()
  3405.  
  3406.             editor.OnSelect:Connect(function(col)
  3407.                 if not editor.CurrentProp then return end
  3408.                 local typeName = editor.CurrentProp.ValueType.Name
  3409.                 if typeName ~= "Color3" and typeName ~= "BrickColor" then return end
  3410.  
  3411.                 local colVal = (typeName == "Color3" and col or BrickColor.new(col))
  3412.  
  3413.                 if editor.CurrentProp == inputProp then inputProp = nil end
  3414.                 Properties.SetProp(editor.CurrentProp,colVal)
  3415.             end)
  3416.  
  3417.             Properties.ColorEditor = editor
  3418.         end
  3419.  
  3420.         editor.CurrentProp = prop
  3421.         if col then
  3422.             editor:SetColor(col)
  3423.         else
  3424.             local firstVal = Properties.GetFirstPropVal(prop)
  3425.             if firstVal then editor:SetColor(firstVal) end
  3426.         end
  3427.         editor:Show()
  3428.     end
  3429.  
  3430.     Properties.DisplayNumberSequenceEditor = function(prop,seq)
  3431.         local editor = Properties.NumberSequenceEditor
  3432.         if not editor then
  3433.             editor = Lib.NumberSequenceEditor.new()
  3434.  
  3435.             editor.OnSelect:Connect(function(val)
  3436.                 if not editor.CurrentProp or editor.CurrentProp.ValueType.Name ~= "NumberSequence" then return end
  3437.  
  3438.                 if editor.CurrentProp == inputProp then inputProp = nil end
  3439.                 Properties.SetProp(editor.CurrentProp,val)
  3440.             end)
  3441.  
  3442.             Properties.NumberSequenceEditor = editor
  3443.         end
  3444.  
  3445.         editor.CurrentProp = prop
  3446.         if seq then
  3447.             editor:SetSequence(seq)
  3448.         else
  3449.             local firstVal = Properties.GetFirstPropVal(prop)
  3450.             if firstVal then editor:SetSequence(firstVal) end
  3451.         end
  3452.         editor:Show()
  3453.     end
  3454.  
  3455.     Properties.DisplayColorSequenceEditor = function(prop,seq)
  3456.         local editor = Properties.ColorSequenceEditor
  3457.         if not editor then
  3458.             editor = Lib.ColorSequenceEditor.new()
  3459.  
  3460.             editor.OnSelect:Connect(function(val)
  3461.                 if not editor.CurrentProp or editor.CurrentProp.ValueType.Name ~= "ColorSequence" then return end
  3462.  
  3463.                 if editor.CurrentProp == inputProp then inputProp = nil end
  3464.                 Properties.SetProp(editor.CurrentProp,val)
  3465.             end)
  3466.  
  3467.             Properties.ColorSequenceEditor = editor
  3468.         end
  3469.  
  3470.         editor.CurrentProp = prop
  3471.         if seq then
  3472.             editor:SetSequence(seq)
  3473.         else
  3474.             local firstVal = Properties.GetFirstPropVal(prop)
  3475.             if firstVal then editor:SetSequence(firstVal) end
  3476.         end
  3477.         editor:Show()
  3478.     end
  3479.  
  3480.     Properties.GetFirstPropVal = function(prop)
  3481.         local first = Properties.FindFirstObjWhichIsA(prop.Class)
  3482.         if first then
  3483.             return Properties.GetPropVal(prop,first)
  3484.         end
  3485.     end
  3486.  
  3487.     Properties.GetPropVal = function(prop,obj)
  3488.         if prop.MultiType then return "<Multiple Types>" end
  3489.         if not obj then return end
  3490.  
  3491.         local propVal
  3492.         if prop.IsAttribute then
  3493.             propVal = getAttribute(obj,prop.AttributeName)
  3494.             if propVal == nil then return nil end
  3495.  
  3496.             local typ = typeof(propVal)
  3497.             local currentType = Properties.TypeNameConvert[typ] or typ
  3498.             if prop.RootType then
  3499.                 if prop.RootType.Name ~= currentType then
  3500.                     return nil
  3501.                 end
  3502.             elseif prop.ValueType.Name ~= currentType then
  3503.                 return nil
  3504.             end
  3505.         else
  3506.             propVal = obj[prop.Name]
  3507.         end
  3508.         if prop.SubName then
  3509.             local indexes = string.split(prop.SubName,".")
  3510.             for i = 1,#indexes do
  3511.                 local indexName = indexes[i]
  3512.                 if #indexName > 0 and propVal then
  3513.                     propVal = propVal[indexName]
  3514.                 end
  3515.             end
  3516.         end
  3517.  
  3518.         return propVal
  3519.     end
  3520.  
  3521.     Properties.SelectObject = function(obj)
  3522.         if inputProp and inputProp.ValueType.Category == "Class" then
  3523.             local prop = inputProp
  3524.             inputProp = nil
  3525.  
  3526.             if isa(obj,prop.ValueType.Name) then
  3527.                 Properties.SetProp(prop,obj)
  3528.             else
  3529.                 Properties.Refresh()
  3530.             end
  3531.  
  3532.             return true
  3533.         end
  3534.  
  3535.         return false
  3536.     end
  3537.  
  3538.     Properties.DisplayProp = function(prop,entryIndex)
  3539.         local propName = prop.Name
  3540.         local typeData = prop.ValueType
  3541.         local typeName = typeData.Name
  3542.         local tags = prop.Tags
  3543.         local gName = prop.Class.."."..prop.Name..(prop.SubName or "")
  3544.         local propObj = autoUpdateObjs[gName]
  3545.         local entryData = propEntries[entryIndex]
  3546.         local UDim2 = UDim2
  3547.  
  3548.         local guiElems = entryData.GuiElems
  3549.         local valueFrame = guiElems.ValueFrame
  3550.         local valueBox = guiElems.ValueBox
  3551.         local colorButton = guiElems.ColorButton
  3552.         local colorPreview = guiElems.ColorPreview
  3553.         local gradient = guiElems.Gradient
  3554.         local enumArrow = guiElems.EnumArrow
  3555.         local checkbox = guiElems.Checkbox
  3556.         local rightButton = guiElems.RightButton
  3557.         local soundPreview = guiElems.SoundPreview
  3558.  
  3559.         local propVal = Properties.GetPropVal(prop,propObj)
  3560.         local inputFullName = inputProp and (inputProp.Class.."."..inputProp.Name..(inputProp.SubName or ""))
  3561.  
  3562.         local offset = 4
  3563.         local endOffset = 6
  3564.  
  3565.         -- Offsetting the ValueBox for ValueType specific buttons
  3566.         if (typeName == "Color3" or typeName == "BrickColor" or typeName == "ColorSequence") then
  3567.             colorButton.Visible = true
  3568.             enumArrow.Visible = false
  3569.             if propVal then
  3570.                 gradient.Color = (typeName == "Color3" and ColorSequence.new(propVal)) or (typeName == "BrickColor" and ColorSequence.new(propVal.Color)) or propVal
  3571.             else
  3572.                 gradient.Color = ColorSequence.new(Color3.new(1,1,1))
  3573.             end
  3574.             colorPreview.BorderColor3 = (typeName == "ColorSequence" and Color3.new(1,1,1) or Color3.new(0,0,0))
  3575.             offset = 22
  3576.             endOffset = 24 + (typeName == "ColorSequence" and 20 or 0)
  3577.         elseif typeData.Category == "Enum" then
  3578.             colorButton.Visible = false
  3579.             enumArrow.Visible = not prop.Tags.ReadOnly
  3580.             endOffset = 22
  3581.         elseif (gName == inputFullName and typeData.Category == "Class") or typeName == "NumberSequence" then
  3582.             colorButton.Visible = false
  3583.             enumArrow.Visible = false
  3584.             endOffset = 26
  3585.         else
  3586.             colorButton.Visible = false
  3587.             enumArrow.Visible = false
  3588.         end
  3589.  
  3590.         valueBox.Position = UDim2.new(0,offset,0,0)
  3591.         valueBox.Size = UDim2.new(1,-endOffset,1,0)
  3592.  
  3593.         -- Right button
  3594.         if inputFullName == gName and typeData.Category == "Class" then
  3595.             Main.MiscIcons:DisplayByKey(guiElems.RightButtonIcon, "Delete")
  3596.             guiElems.RightButtonIcon.Visible = true
  3597.             rightButton.Text = ""
  3598.             rightButton.Visible = true
  3599.         elseif typeName == "NumberSequence" or typeName == "ColorSequence" then
  3600.             guiElems.RightButtonIcon.Visible = false
  3601.             rightButton.Text = "..."
  3602.             rightButton.Visible = true
  3603.         else
  3604.             rightButton.Visible = false
  3605.         end
  3606.  
  3607.         -- Displays the correct ValueBox for the ValueType, and sets it to the prop value
  3608.         if typeName == "bool" or typeName == "PhysicalProperties" then
  3609.             valueBox.Visible = false
  3610.             checkbox.Visible = true
  3611.             soundPreview.Visible = false
  3612.             checkboxes[entryIndex].Disabled = tags.ReadOnly
  3613.             if typeName == "PhysicalProperties" and autoUpdateObjs[gName] then
  3614.                 checkboxes[entryIndex]:SetState(propVal and true or false)
  3615.             else
  3616.                 checkboxes[entryIndex]:SetState(propVal)
  3617.             end
  3618.         elseif typeName == "SoundPlayer" then
  3619.             valueBox.Visible = false
  3620.             checkbox.Visible = false
  3621.             soundPreview.Visible = true
  3622.             local playing = Properties.PreviewSound and Properties.PreviewSound.Playing
  3623.             Main.MiscIcons:DisplayByKey(soundPreview.ControlButton.Icon, playing and "Pause" or "Play")
  3624.         else
  3625.             valueBox.Visible = true
  3626.             checkbox.Visible = false
  3627.             soundPreview.Visible = false
  3628.  
  3629.             if propVal ~= nil then
  3630.                 if typeName == "Color3" then
  3631.                     valueBox.Text = "["..Lib.ColorToBytes(propVal).."]"
  3632.                 elseif typeData.Category == "Enum" then
  3633.                     valueBox.Text = propVal.Name
  3634.                 elseif Properties.RoundableTypes[typeName] and Settings.Properties.NumberRounding then
  3635.                     local rawStr = Properties.ValueToString(prop,propVal)
  3636.                     valueBox.Text = rawStr:gsub("-?%d+%.%d+",function(num)
  3637.                         return tostring(tonumber(("%."..Settings.Properties.NumberRounding.."f"):format(num)))
  3638.                     end)
  3639.                 else
  3640.                     valueBox.Text = Properties.ValueToString(prop,propVal)
  3641.                 end
  3642.             else
  3643.                 valueBox.Text = ""
  3644.             end
  3645.  
  3646.             valueBox.TextColor3 = tags.ReadOnly and Settings.Theme.PlaceholderText or Settings.Theme.Text
  3647.         end
  3648.     end
  3649.  
  3650.     Properties.Refresh = function()
  3651.         local maxEntries = math.max(math.ceil((propsFrame.AbsoluteSize.Y) / 23),0) 
  3652.         local maxX = propsFrame.AbsoluteSize.X
  3653.         local valueWidth = math.max(Properties.MinInputWidth,maxX-Properties.ViewWidth)
  3654.         local inputPropVisible = false
  3655.         local isa = game["Run Service"].Parent.IsA
  3656.         local UDim2 = UDim2
  3657.         local stringSplit = string.split
  3658.         local scaleType = Settings.Properties.ScaleType
  3659.  
  3660.         -- Clear connections
  3661.         for i = 1,#propCons do
  3662.             propCons[i]:Disconnect()
  3663.         end
  3664.         table.clear(propCons)
  3665.  
  3666.         -- Hide full name viewer
  3667.         Properties.FullNameFrame.Visible = false
  3668.         Properties.FullNameFrameAttach.Disable()
  3669.  
  3670.         for i = 1,maxEntries do
  3671.             local entryData = propEntries[i]
  3672.             if not propEntries[i] then entryData = Properties.NewPropEntry(i) propEntries[i] = entryData end
  3673.  
  3674.             local entry = entryData.Gui
  3675.             local guiElems = entryData.GuiElems
  3676.             local nameFrame = guiElems.NameFrame
  3677.             local propNameLabel = guiElems.PropName
  3678.             local valueFrame = guiElems.ValueFrame
  3679.             local expand = guiElems.Expand
  3680.             local valueBox = guiElems.ValueBox
  3681.             local propNameBox = guiElems.PropName
  3682.             local rightButton = guiElems.RightButton
  3683.             local editAttributeButton = guiElems.EditAttributeButton
  3684.             local toggleAttributes = guiElems.ToggleAttributes
  3685.  
  3686.             local prop = viewList[i + Properties.Index]
  3687.             if prop then
  3688.                 local entryXOffset = (scaleType == 0 and scrollH.Index or 0)
  3689.                 entry.Visible = true
  3690.                 entry.Position = UDim2.new(0,-entryXOffset,0,entry.Position.Y.Offset)
  3691.                 entry.Size = UDim2.new(scaleType == 0 and 0 or 1, scaleType == 0 and Properties.ViewWidth + valueWidth or 0,0,22)
  3692.  
  3693.                 if prop.SpecialRow then
  3694.                     if prop.SpecialRow == "AddAttribute" then
  3695.                         nameFrame.Visible = false
  3696.                         valueFrame.Visible = false
  3697.                         guiElems.RowButton.Visible = true
  3698.                     end
  3699.                 else
  3700.                     -- Revert special row stuff
  3701.                     nameFrame.Visible = true
  3702.                     guiElems.RowButton.Visible = false
  3703.  
  3704.                     local depth = Properties.EntryIndent*(prop.Depth or 1)
  3705.                     local leftOffset = depth + Properties.EntryOffset
  3706.                     nameFrame.Position = UDim2.new(0,leftOffset,0,0)
  3707.                     propNameLabel.Size = UDim2.new(1,-2 - (scaleType == 0 and 0 or 6),1,0)
  3708.  
  3709.                     local gName = (prop.CategoryName and "CAT_"..prop.CategoryName) or prop.Class.."."..prop.Name..(prop.SubName or "")
  3710.  
  3711.                     if prop.CategoryName then
  3712.                         entry.BackgroundColor3 = Settings.Theme.Main1
  3713.                         valueFrame.Visible = false
  3714.  
  3715.                         propNameBox.Text = prop.CategoryName
  3716.                         propNameBox.Font = Enum.Font.SourceSansBold
  3717.                         expand.Visible = true
  3718.                         propNameBox.TextColor3 = Settings.Theme.Text
  3719.                         nameFrame.BackgroundTransparency = 1
  3720.                         nameFrame.Size = UDim2.new(1,0,1,0)
  3721.                         editAttributeButton.Visible = false
  3722.  
  3723.                         local showingAttrs = Settings.Properties.ShowAttributes
  3724.                         toggleAttributes.Position = UDim2.new(1,-85-leftOffset,0,0)
  3725.                         toggleAttributes.Text = (showingAttrs and "[Setting: ON]" or "[Setting: OFF]")
  3726.                         toggleAttributes.TextColor3 = Settings.Theme.Text
  3727.                         toggleAttributes.Visible = (prop.CategoryName == "Attributes")
  3728.                     else
  3729.                         local propName = prop.Name
  3730.                         local typeData = prop.ValueType
  3731.                         local typeName = typeData.Name
  3732.                         local tags = prop.Tags
  3733.                         local propObj = autoUpdateObjs[gName]
  3734.  
  3735.                         local attributeOffset = (prop.IsAttribute and 20 or 0)
  3736.                         editAttributeButton.Visible = (prop.IsAttribute and not prop.RootType)
  3737.                         toggleAttributes.Visible = false
  3738.  
  3739.                         -- Moving around the frames
  3740.                         if scaleType == 0 then
  3741.                             nameFrame.Size = UDim2.new(0,Properties.ViewWidth - leftOffset - 1,1,0)
  3742.                             valueFrame.Position = UDim2.new(0,Properties.ViewWidth,0,0)
  3743.                             valueFrame.Size = UDim2.new(0,valueWidth - attributeOffset,1,0)
  3744.                         else
  3745.                             nameFrame.Size = UDim2.new(0.5,-leftOffset - 1,1,0)
  3746.                             valueFrame.Position = UDim2.new(0.5,0,0,0)
  3747.                             valueFrame.Size = UDim2.new(0.5,-attributeOffset,1,0)
  3748.                         end
  3749.  
  3750.                         local nameArr = stringSplit(gName,".")
  3751.                         propNameBox.Text = prop.DisplayName or nameArr[#nameArr]
  3752.                         propNameBox.Font = Enum.Font.SourceSans
  3753.                         entry.BackgroundColor3 = Settings.Theme.Main2
  3754.                         valueFrame.Visible = true
  3755.  
  3756.                         expand.Visible = typeData.Category == "DataType" and Properties.ExpandableTypes[typeName] or Properties.ExpandableProps[gName]
  3757.                         propNameBox.TextColor3 = tags.ReadOnly and Settings.Theme.PlaceholderText or Settings.Theme.Text
  3758.  
  3759.                         -- Display property value
  3760.                         Properties.DisplayProp(prop,i)
  3761.                         if propObj then
  3762.                             if prop.IsAttribute then
  3763.                                 propCons[#propCons+1] = getAttributeChangedSignal(propObj,prop.AttributeName):Connect(function()
  3764.                                     Properties.DisplayProp(prop,i)
  3765.                                 end)
  3766.                             else
  3767.                                 propCons[#propCons+1] = getPropChangedSignal(propObj,propName):Connect(function()
  3768.                                     Properties.DisplayProp(prop,i)
  3769.                                 end)
  3770.                             end
  3771.                         end
  3772.  
  3773.                         -- Position and resize Input Box
  3774.                         local beforeVisible = valueBox.Visible
  3775.                         local inputFullName = inputProp and (inputProp.Class.."."..inputProp.Name..(inputProp.SubName or ""))
  3776.                         if gName == inputFullName then
  3777.                             nameFrame.BackgroundColor3 = Settings.Theme.ListSelection
  3778.                             nameFrame.BackgroundTransparency = 0
  3779.                             if typeData.Category == "Class" or typeData.Category == "Enum" or typeName == "BrickColor" then
  3780.                                 valueFrame.BackgroundColor3 = Settings.Theme.TextBox
  3781.                                 valueFrame.BackgroundTransparency = 0
  3782.                                 valueBox.Visible = true
  3783.                             else
  3784.                                 inputPropVisible = true
  3785.                                 local scale = (scaleType == 0 and 0 or 0.5)
  3786.                                 local offset = (scaleType == 0 and Properties.ViewWidth-scrollH.Index or 0)
  3787.                                 local endOffset = 0
  3788.  
  3789.                                 if typeName == "Color3" or typeName == "ColorSequence" then
  3790.                                     offset = offset + 22
  3791.                                 end
  3792.  
  3793.                                 if typeName == "NumberSequence" or typeName == "ColorSequence" then
  3794.                                     endOffset = 20
  3795.                                 end
  3796.  
  3797.                                 inputBox.Position = UDim2.new(scale,offset,0,entry.Position.Y.Offset)
  3798.                                 inputBox.Size = UDim2.new(1-scale,-offset-endOffset-attributeOffset,0,22)
  3799.                                 inputBox.Visible = true
  3800.                                 valueBox.Visible = false
  3801.                             end
  3802.                         else
  3803.                             nameFrame.BackgroundColor3 = Settings.Theme.Main1
  3804.                             nameFrame.BackgroundTransparency = 1
  3805.                             valueFrame.BackgroundColor3 = Settings.Theme.Main1
  3806.                             valueFrame.BackgroundTransparency = 1
  3807.                             valueBox.Visible = beforeVisible
  3808.                         end
  3809.                     end
  3810.  
  3811.                     -- Expand
  3812.                     if prop.CategoryName or Properties.ExpandableTypes[prop.ValueType and prop.ValueType.Name] or Properties.ExpandableProps[gName] then
  3813.                         if Lib.CheckMouseInGui(expand) then
  3814.                             Main.MiscIcons:DisplayByKey(expand.Icon, expanded[gName] and "Collapse_Over" or "Expand_Over")
  3815.                         else
  3816.                             Main.MiscIcons:DisplayByKey(expand.Icon, expanded[gName] and "Collapse" or "Expand")
  3817.                         end
  3818.                         expand.Visible = true
  3819.                     else
  3820.                         expand.Visible = false
  3821.                     end
  3822.                 end
  3823.                 entry.Visible = true
  3824.             else
  3825.                 entry.Visible = false
  3826.             end
  3827.         end
  3828.  
  3829.         if not inputPropVisible then
  3830.             inputBox.Visible = false
  3831.         end
  3832.  
  3833.         for i = maxEntries+1,#propEntries do
  3834.             propEntries[i].Gui:Destroy()
  3835.             propEntries[i] = nil
  3836.             checkboxes[i] = nil
  3837.         end
  3838.     end
  3839.  
  3840.     Properties.SetProp = function(prop,val,noupdate,prevAttribute)
  3841.         local sList = Explorer.Selection.List
  3842.         local propName = prop.Name
  3843.         local subName = prop.SubName
  3844.         local propClass = prop.Class
  3845.         local typeData = prop.ValueType
  3846.         local typeName = typeData.Name
  3847.         local attributeName = prop.AttributeName
  3848.         local rootTypeData = prop.RootType
  3849.         local rootTypeName = rootTypeData and rootTypeData.Name
  3850.         local fullName = prop.Class.."."..prop.Name..(prop.SubName or "")
  3851.         local Vector3 = Vector3
  3852.  
  3853.         for i = 1,#sList do
  3854.             local node = sList[i]
  3855.             local obj = node.Obj
  3856.  
  3857.             if isa(obj,propClass) then
  3858.                 pcall(function()
  3859.                     local setVal = val
  3860.                     local root
  3861.                     if prop.IsAttribute then
  3862.                         root = getAttribute(obj,attributeName)
  3863.                     else
  3864.                         root = obj[propName]
  3865.                     end
  3866.  
  3867.                     if prevAttribute then
  3868.                         if prevAttribute.ValueType.Name == typeName then
  3869.                             setVal = getAttribute(obj,prevAttribute.AttributeName) or setVal
  3870.                         end
  3871.                         setAttribute(obj,prevAttribute.AttributeName,nil)
  3872.                     end
  3873.  
  3874.                     if rootTypeName then
  3875.                         if rootTypeName == "Vector2" then
  3876.                             setVal = Vector2.new((subName == ".X" and setVal) or root.X, (subName == ".Y" and setVal) or root.Y)
  3877.                         elseif rootTypeName == "Vector3" then
  3878.                             setVal = Vector3.new((subName == ".X" and setVal) or root.X, (subName == ".Y" and setVal) or root.Y, (subName == ".Z" and setVal) or root.Z)
  3879.                         elseif rootTypeName == "UDim" then
  3880.                             setVal = UDim.new((subName == ".Scale" and setVal) or root.Scale, (subName == ".Offset" and setVal) or root.Offset)
  3881.                         elseif rootTypeName == "UDim2" then
  3882.                             local rootX,rootY = root.X,root.Y
  3883.                             local X_UDim = (subName == ".X" and setVal) or UDim.new((subName == ".X.Scale" and setVal) or rootX.Scale, (subName == ".X.Offset" and setVal) or rootX.Offset)
  3884.                             local Y_UDim = (subName == ".Y" and setVal) or UDim.new((subName == ".Y.Scale" and setVal) or rootY.Scale, (subName == ".Y.Offset" and setVal) or rootY.Offset)
  3885.                             setVal = UDim2.new(X_UDim,Y_UDim)
  3886.                         elseif rootTypeName == "CFrame" then
  3887.                             local rootPos,rootRight,rootUp,rootLook = root.Position,root.RightVector,root.UpVector,root.LookVector
  3888.                             local pos = (subName == ".Position" and setVal) or Vector3.new((subName == ".Position.X" and setVal) or rootPos.X, (subName == ".Position.Y" and setVal) or rootPos.Y, (subName == ".Position.Z" and setVal) or rootPos.Z)
  3889.                             local rightV = (subName == ".RightVector" and setVal) or Vector3.new((subName == ".RightVector.X" and setVal) or rootRight.X, (subName == ".RightVector.Y" and setVal) or rootRight.Y, (subName == ".RightVector.Z" and setVal) or rootRight.Z)
  3890.                             local upV = (subName == ".UpVector" and setVal) or Vector3.new((subName == ".UpVector.X" and setVal) or rootUp.X, (subName == ".UpVector.Y" and setVal) or rootUp.Y, (subName == ".UpVector.Z" and setVal) or rootUp.Z)
  3891.                             local lookV = (subName == ".LookVector" and setVal) or Vector3.new((subName == ".LookVector.X" and setVal) or rootLook.X, (subName == ".RightVector.Y" and setVal) or rootLook.Y, (subName == ".RightVector.Z" and setVal) or rootLook.Z)
  3892.                             setVal = CFrame.fromMatrix(pos,rightV,upV,-lookV)
  3893.                         elseif rootTypeName == "Rect" then
  3894.                             local rootMin,rootMax = root.Min,root.Max
  3895.                             local min = Vector2.new((subName == ".Min.X" and setVal) or rootMin.X, (subName == ".Min.Y" and setVal) or rootMin.Y)
  3896.                             local max = Vector2.new((subName == ".Max.X" and setVal) or rootMax.X, (subName == ".Max.Y" and setVal) or rootMax.Y)
  3897.                             setVal = Rect.new(min,max)
  3898.                         elseif rootTypeName == "PhysicalProperties" then
  3899.                             local rootProps = PhysicalProperties.new(obj.Material)
  3900.                             local density = (subName == ".Density" and setVal) or (root and root.Density) or rootProps.Density
  3901.                             local friction = (subName == ".Friction" and setVal) or (root and root.Friction) or rootProps.Friction
  3902.                             local elasticity = (subName == ".Elasticity" and setVal) or (root and root.Elasticity) or rootProps.Elasticity
  3903.                             local frictionWeight = (subName == ".FrictionWeight" and setVal) or (root and root.FrictionWeight) or rootProps.FrictionWeight
  3904.                             local elasticityWeight = (subName == ".ElasticityWeight" and setVal) or (root and root.ElasticityWeight) or rootProps.ElasticityWeight
  3905.                             setVal = PhysicalProperties.new(density,friction,elasticity,frictionWeight,elasticityWeight)
  3906.                         elseif rootTypeName == "Ray" then
  3907.                             local rootOrigin,rootDirection = root.Origin,root.Direction
  3908.                             local origin = (subName == ".Origin" and setVal) or Vector3.new((subName == ".Origin.X" and setVal) or rootOrigin.X, (subName == ".Origin.Y" and setVal) or rootOrigin.Y, (subName == ".Origin.Z" and setVal) or rootOrigin.Z)
  3909.                             local direction = (subName == ".Direction" and setVal) or Vector3.new((subName == ".Direction.X" and setVal) or rootDirection.X, (subName == ".Direction.Y" and setVal) or rootDirection.Y, (subName == ".Direction.Z" and setVal) or rootDirection.Z)
  3910.                             setVal = Ray.new(origin,direction)
  3911.                         elseif rootTypeName == "Faces" then
  3912.                             local faces = {}
  3913.                             local faceList = {"Back","Bottom","Front","Left","Right","Top"}
  3914.                             for _,face in pairs(faceList) do
  3915.                                 local val
  3916.                                 if subName == "."..face then
  3917.                                     val = setVal
  3918.                                 else
  3919.                                     val = root[face]
  3920.                                 end
  3921.                                 if val then faces[#faces+1] = Enum.NormalId[face] end
  3922.                             end
  3923.                             setVal = Faces.new(unpack(faces))
  3924.                         elseif rootTypeName == "Axes" then
  3925.                             local axes = {}
  3926.                             local axesList = {"X","Y","Z"}
  3927.                             for _,axe in pairs(axesList) do
  3928.                                 local val
  3929.                                 if subName == "."..axe then
  3930.                                     val = setVal
  3931.                                 else
  3932.                                     val = root[axe]
  3933.                                 end
  3934.                                 if val then axes[#axes+1] = Enum.Axis[axe] end
  3935.                             end
  3936.                             setVal = Axes.new(unpack(axes))
  3937.                         elseif rootTypeName == "NumberRange" then
  3938.                             setVal = NumberRange.new(subName == ".Min" and setVal or root.Min, subName == ".Max" and setVal or root.Max)
  3939.                         end
  3940.                     end
  3941.  
  3942.                     if typeName == "PhysicalProperties" and setVal then
  3943.                         setVal = root or PhysicalProperties.new(obj.Material)
  3944.                     end
  3945.  
  3946.                     if prop.IsAttribute then
  3947.                         setAttribute(obj,attributeName,setVal)
  3948.                     else
  3949.                         obj[propName] = setVal
  3950.                     end
  3951.                 end)
  3952.             end
  3953.         end
  3954.  
  3955.         if not noupdate then
  3956.             Properties.ComputeConflicts(prop)
  3957.         end
  3958.     end
  3959.  
  3960.     Properties.InitInputBox = function()
  3961.         inputBox = create({
  3962.             {1,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderSizePixel=0,Name="InputBox",Size=UDim2.new(0,200,0,22),Visible=false,ZIndex=2,}},
  3963.             {2,"TextBox",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BackgroundTransparency=1,BorderColor3=Color3.new(0.062745101749897,0.51764708757401,1),BorderSizePixel=0,ClearTextOnFocus=false,Font=3,Parent={1},PlaceholderColor3=Color3.new(0.69803923368454,0.69803923368454,0.69803923368454),Position=UDim2.new(0,3,0,0),Size=UDim2.new(1,-6,1,0),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,ZIndex=2,}},
  3964.         })
  3965.         inputTextBox = inputBox.TextBox
  3966.         inputBox.BackgroundColor3 = Settings.Theme.TextBox
  3967.         inputBox.Parent = Properties.Window.GuiElems.Content.List
  3968.  
  3969.         inputTextBox.FocusLost:Connect(function()
  3970.             if not inputProp then return end
  3971.  
  3972.             local prop = inputProp
  3973.             inputProp = nil
  3974.             local val = Properties.StringToValue(prop,inputTextBox.Text)
  3975.             if val then Properties.SetProp(prop,val) else Properties.Refresh() end
  3976.         end)
  3977.  
  3978.         inputTextBox.Focused:Connect(function()
  3979.             inputTextBox.SelectionStart = 1
  3980.             inputTextBox.CursorPosition = #inputTextBox.Text + 1
  3981.         end)
  3982.  
  3983.         Lib.ViewportTextBox.convert(inputTextBox)
  3984.     end
  3985.  
  3986.     Properties.SetInputProp = function(prop,entryIndex,special)
  3987.         local typeData = prop.ValueType
  3988.         local typeName = typeData.Name
  3989.         local fullName = prop.Class.."."..prop.Name..(prop.SubName or "")
  3990.         local propObj = autoUpdateObjs[fullName]
  3991.         local propVal = Properties.GetPropVal(prop,propObj)
  3992.  
  3993.         if prop.Tags.ReadOnly then return end
  3994.  
  3995.         inputProp = prop
  3996.         if special then
  3997.             if special == "color" then
  3998.                 if typeName == "Color3" then
  3999.                     inputTextBox.Text = propVal and Properties.ValueToString(prop,propVal) or ""
  4000.                     Properties.DisplayColorEditor(prop,propVal)
  4001.                 elseif typeName == "BrickColor" then
  4002.                     Properties.DisplayBrickColorEditor(prop,entryIndex,propVal)
  4003.                 elseif typeName == "ColorSequence" then
  4004.                     inputTextBox.Text = propVal and Properties.ValueToString(prop,propVal) or ""
  4005.                     Properties.DisplayColorSequenceEditor(prop,propVal)
  4006.                 end
  4007.             elseif special == "right" then
  4008.                 if typeName == "NumberSequence" then
  4009.                     inputTextBox.Text = propVal and Properties.ValueToString(prop,propVal) or ""
  4010.                     Properties.DisplayNumberSequenceEditor(prop,propVal)
  4011.                 elseif typeName == "ColorSequence" then
  4012.                     inputTextBox.Text = propVal and Properties.ValueToString(prop,propVal) or ""
  4013.                     Properties.DisplayColorSequenceEditor(prop,propVal)
  4014.                 end
  4015.             end
  4016.         else
  4017.             if Properties.IsTextEditable(prop) then
  4018.                 inputTextBox.Text = propVal and Properties.ValueToString(prop,propVal) or ""
  4019.                 inputTextBox:CaptureFocus()
  4020.             elseif typeData.Category == "Enum" then
  4021.                 Properties.DisplayEnumDropdown(entryIndex)
  4022.             elseif typeName == "BrickColor" then
  4023.                 Properties.DisplayBrickColorEditor(prop,entryIndex,propVal)
  4024.             end
  4025.         end
  4026.         Properties.Refresh()
  4027.     end
  4028.  
  4029.     Properties.InitSearch = function()
  4030.         local searchBox = Properties.GuiElems.ToolBar.SearchFrame.SearchBox
  4031.  
  4032.         Lib.ViewportTextBox.convert(searchBox)
  4033.  
  4034.         searchBox:GetPropertyChangedSignal("Text"):Connect(function()
  4035.             Properties.SearchText = searchBox.Text
  4036.             Properties.Update()
  4037.             Properties.Refresh()
  4038.         end)
  4039.     end
  4040.  
  4041.     Properties.InitEntryStuff = function()
  4042.         Properties.EntryTemplate = create({
  4043.             {1,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.1294117718935,0.1294117718935,0.1294117718935),Font=3,Name="Entry",Position=UDim2.new(0,1,0,1),Size=UDim2.new(0,250,0,22),Text="",TextSize=14,}},
  4044.             {2,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BackgroundTransparency=1,BorderColor3=Color3.new(0.33725491166115,0.49019610881805,0.73725491762161),BorderSizePixel=0,Name="NameFrame",Parent={1},Position=UDim2.new(0,20,0,0),Size=UDim2.new(1,-40,1,0),}},
  4045.             {3,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="PropName",Parent={2},Position=UDim2.new(0,2,0,0),Size=UDim2.new(1,-2,1,0),Text="Anchored",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.10000000149012,TextTruncate=1,TextXAlignment=0,}},
  4046.             {4,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClipsDescendants=true,Font=3,Name="Expand",Parent={2},Position=UDim2.new(0,-20,0,1),Size=UDim2.new(0,20,0,20),Text="",TextSize=14,Visible=false,}},
  4047.             {5,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5642383285",ImageRectOffset=Vector2.new(144,16),ImageRectSize=Vector2.new(16,16),Name="Icon",Parent={4},Position=UDim2.new(0,2,0,2),ScaleType=4,Size=UDim2.new(0,16,0,16),}},
  4048.             {6,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=4,Name="ToggleAttributes",Parent={2},Position=UDim2.new(1,-85,0,0),Size=UDim2.new(0,85,0,22),Text="[SETTING: OFF]",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.10000000149012,Visible=false,}},
  4049.             {7,"Frame",{BackgroundColor3=Color3.new(0.04313725605607,0.35294118523598,0.68627452850342),BackgroundTransparency=1,BorderColor3=Color3.new(0.33725491166115,0.49019607901573,0.73725491762161),BorderSizePixel=0,Name="ValueFrame",Parent={1},Position=UDim2.new(1,-100,0,0),Size=UDim2.new(0,80,1,0),}},
  4050.             {8,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderColor3=Color3.new(0.33725491166115,0.49019610881805,0.73725491762161),BorderSizePixel=0,Name="Line",Parent={7},Position=UDim2.new(0,-1,0,0),Size=UDim2.new(0,1,1,0),}},
  4051.             {9,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="ColorButton",Parent={7},Size=UDim2.new(0,20,0,22),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,Visible=false,}},
  4052.             {10,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderColor3=Color3.new(0,0,0),Name="ColorPreview",Parent={9},Position=UDim2.new(0,5,0,6),Size=UDim2.new(0,10,0,10),}},
  4053.             {11,"UIGradient",{Parent={10},}},
  4054.             {12,"Frame",{BackgroundTransparency=1,Name="EnumArrow",Parent={7},Position=UDim2.new(1,-16,0,3),Size=UDim2.new(0,16,0,16),Visible=false,}},
  4055.             {13,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={12},Position=UDim2.new(0,8,0,9),Size=UDim2.new(0,1,0,1),}},
  4056.             {14,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={12},Position=UDim2.new(0,7,0,8),Size=UDim2.new(0,3,0,1),}},
  4057.             {15,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={12},Position=UDim2.new(0,6,0,7),Size=UDim2.new(0,5,0,1),}},
  4058.             {16,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="ValueBox",Parent={7},Position=UDim2.new(0,4,0,0),Size=UDim2.new(1,-8,1,0),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.10000000149012,TextTruncate=1,TextXAlignment=0,}},
  4059.             {17,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="RightButton",Parent={7},Position=UDim2.new(1,-20,0,0),Size=UDim2.new(0,20,0,22),Text="...",TextColor3=Color3.new(1,1,1),TextSize=14,Visible=false,}},
  4060.             {18,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="SettingsButton",Parent={7},Position=UDim2.new(1,-20,0,0),Size=UDim2.new(0,20,0,22),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,Visible=false,}},
  4061.             {19,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="SoundPreview",Parent={7},Size=UDim2.new(1,0,1,0),Visible=false,}},
  4062.             {20,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="ControlButton",Parent={19},Size=UDim2.new(0,20,0,22),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  4063.             {21,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5642383285",ImageRectOffset=Vector2.new(144,16),ImageRectSize=Vector2.new(16,16),Name="Icon",Parent={20},Position=UDim2.new(0,2,0,3),ScaleType=4,Size=UDim2.new(0,16,0,16),}},
  4064.             {22,"Frame",{BackgroundColor3=Color3.new(0.3137255012989,0.3137255012989,0.3137255012989),BorderSizePixel=0,Name="TimeLine",Parent={19},Position=UDim2.new(0,26,0.5,-1),Size=UDim2.new(1,-34,0,2),}},
  4065.             {23,"Frame",{BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.1294117718935,0.1294117718935,0.1294117718935),Name="Slider",Parent={22},Position=UDim2.new(0,-4,0,-8),Size=UDim2.new(0,8,0,18),}},
  4066.             {24,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="EditAttributeButton",Parent={1},Position=UDim2.new(1,-20,0,0),Size=UDim2.new(0,20,0,22),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  4067.             {25,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5034718180",ImageTransparency=0.20000000298023,Name="Icon",Parent={24},Position=UDim2.new(0,2,0,3),Size=UDim2.new(0,16,0,16),}},
  4068.             {26,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderSizePixel=0,Font=3,Name="RowButton",Parent={1},Size=UDim2.new(1,0,1,0),Text="Add Attribute",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.10000000149012,Visible=false,}},
  4069.         })
  4070.  
  4071.         local fullNameFrame = Lib.Frame.new()
  4072.         local label = Lib.Label.new()
  4073.         label.Parent = fullNameFrame.Gui
  4074.         label.Position = UDim2.new(0,2,0,0)
  4075.         label.Size = UDim2.new(1,-4,1,0)
  4076.         fullNameFrame.Visible = false
  4077.         fullNameFrame.Parent = window.Gui
  4078.  
  4079.         Properties.FullNameFrame = fullNameFrame
  4080.         Properties.FullNameFrameAttach = Lib.AttachTo(fullNameFrame)
  4081.     end
  4082.  
  4083.     Properties.Init = function() -- TODO: MAKE BETTER
  4084.         local guiItems = create({
  4085.             {1,"Folder",{Name="Items",}},
  4086.             {2,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="ToolBar",Parent={1},Size=UDim2.new(1,0,0,22),}},
  4087.             {3,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.1176470592618,0.1176470592618,0.1176470592618),BorderSizePixel=0,Name="SearchFrame",Parent={2},Position=UDim2.new(0,3,0,1),Size=UDim2.new(1,-6,0,18),}},
  4088.             {4,"TextBox",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClearTextOnFocus=false,Font=3,Name="SearchBox",Parent={3},PlaceholderColor3=Color3.new(0.39215689897537,0.39215689897537,0.39215689897537),PlaceholderText="Search properties",Position=UDim2.new(0,4,0,0),Size=UDim2.new(1,-24,0,18),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,}},
  4089.             {5,"UICorner",{CornerRadius=UDim.new(0,2),Parent={3},}},
  4090.             {6,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Reset",Parent={3},Position=UDim2.new(1,-17,0,1),Size=UDim2.new(0,16,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  4091.             {7,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5034718129",ImageColor3=Color3.new(0.39215686917305,0.39215686917305,0.39215686917305),Parent={6},Size=UDim2.new(0,16,0,16),}},
  4092.             {8,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Refresh",Parent={2},Position=UDim2.new(1,-20,0,1),Size=UDim2.new(0,18,0,18),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,Visible=false,}},
  4093.             {9,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5642310344",Parent={8},Position=UDim2.new(0,3,0,3),Size=UDim2.new(0,12,0,12),}},
  4094.             {10,"Frame",{BackgroundColor3=Color3.new(0.15686275064945,0.15686275064945,0.15686275064945),BorderSizePixel=0,Name="ScrollCorner",Parent={1},Position=UDim2.new(1,-16,1,-16),Size=UDim2.new(0,16,0,16),Visible=false,}},
  4095.             {11,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ClipsDescendants=true,Name="List",Parent={1},Position=UDim2.new(0,0,0,23),Size=UDim2.new(1,0,1,-23),}},
  4096.         })
  4097.  
  4098.         -- Vars
  4099.         categoryOrder =  API.CategoryOrder
  4100.         for category,_ in next,categoryOrder do
  4101.             if not Properties.CollapsedCategories[category] then
  4102.                 expanded["CAT_"..category] = true
  4103.             end
  4104.         end
  4105.         expanded["Sound.SoundId"] = true
  4106.  
  4107.         -- Init window
  4108.         window = Lib.Window.new()
  4109.         Properties.Window = window
  4110.         window:SetTitle("Properties")
  4111.  
  4112.         toolBar = guiItems.ToolBar
  4113.         propsFrame = guiItems.List
  4114.  
  4115.         Properties.GuiElems.ToolBar = toolBar
  4116.         Properties.GuiElems.PropsFrame = propsFrame
  4117.  
  4118.         Properties.InitEntryStuff()
  4119.  
  4120.         -- Window events
  4121.         window.GuiElems.Main:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
  4122.             if Properties.Window:IsContentVisible() then
  4123.                 Properties.UpdateView()
  4124.                 Properties.Refresh()
  4125.             end
  4126.         end)
  4127.         window.OnActivate:Connect(function()
  4128.             Properties.UpdateView()
  4129.             Properties.Update()
  4130.             Properties.Refresh()
  4131.         end)
  4132.         window.OnRestore:Connect(function()
  4133.             Properties.UpdateView()
  4134.             Properties.Update()
  4135.             Properties.Refresh()
  4136.         end)
  4137.  
  4138.         -- Init scrollbars
  4139.         scrollV = Lib.ScrollBar.new()      
  4140.         scrollV.WheelIncrement = 3
  4141.         scrollV.Gui.Position = UDim2.new(1,-16,0,23)
  4142.         scrollV:SetScrollFrame(propsFrame)
  4143.         scrollV.Scrolled:Connect(function()
  4144.             Properties.Index = scrollV.Index
  4145.             Properties.Refresh()
  4146.         end)
  4147.  
  4148.         scrollH = Lib.ScrollBar.new(true)
  4149.         scrollH.Increment = 5
  4150.         scrollH.WheelIncrement = 20
  4151.         scrollH.Gui.Position = UDim2.new(0,0,1,-16)
  4152.         scrollH.Scrolled:Connect(function()
  4153.             Properties.Refresh()
  4154.         end)
  4155.  
  4156.         -- Setup Gui
  4157.         window.GuiElems.Line.Position = UDim2.new(0,0,0,22)
  4158.         toolBar.Parent = window.GuiElems.Content
  4159.         propsFrame.Parent = window.GuiElems.Content
  4160.         guiItems.ScrollCorner.Parent = window.GuiElems.Content
  4161.         scrollV.Gui.Parent = window.GuiElems.Content
  4162.         scrollH.Gui.Parent = window.GuiElems.Content
  4163.         Properties.InitInputBox()
  4164.         Properties.InitSearch()
  4165.     end
  4166.  
  4167.     return Properties
  4168. end
  4169.  
  4170. return {InitDeps = initDeps, InitAfterMain = initAfterMain, Main = main}
  4171. end,
  4172. ScriptViewer = function()
  4173. --[[
  4174.     Script Viewer App Module
  4175.    
  4176.     A script viewer that is basically a notepad
  4177. ]]
  4178.  
  4179. -- Common Locals
  4180. local Main,Lib,Apps,Settings -- Main Containers
  4181. local Explorer, Properties, ScriptViewer, Notebook -- Major Apps
  4182. local API,RMD,env,service,plr,create,createSimple -- Main Locals
  4183.  
  4184. local function initDeps(data)
  4185.     Main = data.Main
  4186.     Lib = data.Lib
  4187.     Apps = data.Apps
  4188.     Settings = data.Settings
  4189.  
  4190.     API = data.API
  4191.     RMD = data.RMD
  4192.     env = data.env
  4193.     service = data.service
  4194.     plr = data.plr
  4195.     create = data.create
  4196.     createSimple = data.createSimple
  4197. end
  4198.  
  4199. local function initAfterMain()
  4200.     Explorer = Apps.Explorer
  4201.     Properties = Apps.Properties
  4202.     ScriptViewer = Apps.ScriptViewer
  4203.     Notebook = Apps.Notebook
  4204. end
  4205.  
  4206. local function main()
  4207.     local ScriptViewer = {}
  4208.     local window, codeFrame
  4209.     local PreviousScr = nil
  4210.  
  4211.     ScriptViewer.ViewScript = function(scr)
  4212.         local success, source = pcall(env.decompile or function() end, scr)
  4213.         if not success or not source then source, PreviousScr = "-- DEX - Source failed to decompile", nil else PreviousScr = scr end
  4214.         codeFrame:SetText(source:gsub("\0", "\\0")) -- Fix stupid breaking script viewer
  4215.         window:Show()
  4216.     end
  4217.  
  4218.     ScriptViewer.Init = function()
  4219.         window = Lib.Window.new()
  4220.         window:SetTitle("Script Viewer")
  4221.         window:Resize(500,400)
  4222.         ScriptViewer.Window = window
  4223.  
  4224.         codeFrame = Lib.CodeFrame.new()
  4225.         codeFrame.Frame.Position = UDim2.new(0,0,0,20)
  4226.         codeFrame.Frame.Size = UDim2.new(1,0,1,-20)
  4227.         codeFrame.Frame.Parent = window.GuiElems.Content
  4228.  
  4229.         -- TODO: REMOVE AND MAKE BETTER
  4230.         local copy = Instance.new("TextButton",window.GuiElems.Content)
  4231.         copy.BackgroundTransparency = 1
  4232.         copy.Size = UDim2.new(0.5,0,0,20)
  4233.         copy.Text = "Copy to Clipboard"
  4234.         copy.TextColor3 = Color3.new(1,1,1)
  4235.  
  4236.         copy.MouseButton1Click:Connect(function()
  4237.             local source = codeFrame:GetText()
  4238.             env.setclipboard(source)
  4239.         end)
  4240.  
  4241.         local save = Instance.new("TextButton",window.GuiElems.Content)
  4242.         save.BackgroundTransparency = 1
  4243.         save.Position = UDim2.new(0.35,0,0,0)
  4244.         save.Size = UDim2.new(0.3,0,0,20)
  4245.         save.Text = "Save to File"
  4246.         save.TextColor3 = Color3.new(1,1,1)
  4247.  
  4248.         save.MouseButton1Click:Connect(function()
  4249.             local source = codeFrame:GetText()
  4250.             local filename = "Place_"..game["Run Service"].Parent.PlaceId.."_Script_"..os.time()..".txt"
  4251.  
  4252.             env.writefile(filename, source)
  4253.             if env.movefileas then
  4254.                 env.movefileas(filename, ".txt")
  4255.             end
  4256.         end)
  4257.  
  4258.         local dumpbtn = Instance.new("TextButton",window.GuiElems.Content)
  4259.         dumpbtn.BackgroundTransparency = 1
  4260.         dumpbtn.Position = UDim2.new(0.7,0,0,0)
  4261.         dumpbtn.Size = UDim2.new(0.3,0,0,20)
  4262.         dumpbtn.Text = "Dump Functions"
  4263.         dumpbtn.TextColor3 = Color3.new(1,1,1)
  4264.  
  4265.         dumpbtn.MouseButton1Click:Connect(function()
  4266.             if PreviousScr ~= nil then
  4267.                 pcall(function()
  4268.                     -- thanks King.Kevin#6025 you'll obviously be credited (no discord tag since that can easily be impersonated)
  4269.                     local getgc = getgc or get_gc_objects
  4270.                     local getupvalues = (debug and debug.getupvalues) or getupvalues or getupvals
  4271.                     local getconstants = (debug and debug.getconstants) or getconstants or getconsts
  4272.                     local getinfo = (debug and (debug.getinfo or debug.info)) or getinfo
  4273.                     local original = ("\n-- // Function Dumper made by King.Kevin\n-- // Script Path: %s\n\n--[["):format(PreviousScr:GetFullName())
  4274.                     local dump = original
  4275.                     local functions, function_count, data_base = {}, 0, {}
  4276.                     function functions:add_to_dump(str, indentation, new_line)
  4277.                         local new_line = new_line or true
  4278.                         dump = dump .. ("%s%s%s"):format(string.rep("    ", indentation), tostring(str), new_line and "\n" or "")
  4279.                     end
  4280.                     function functions:get_function_name(func)
  4281.                         local n = getinfo(func).name
  4282.                         return n ~= "" and n or "Unknown Name"
  4283.                     end
  4284.                     function functions:dump_table(input, indent, index)
  4285.                         local indent = indent < 0 and 0 or indent
  4286.                         functions:add_to_dump(("%s [%s] %s"):format(tostring(index), tostring(typeof(input)), tostring(input)), indent - 1)
  4287.                         local count = 0
  4288.                         for index, value in pairs(input) do
  4289.                             count = count + 1
  4290.                             if type(value) == "function" then
  4291.                                 functions:add_to_dump(("%d [function] = %s"):format(count, functions:get_function_name(value)), indent)
  4292.                             elseif type(value) == "table" then
  4293.                                 if not data_base[value] then
  4294.                                     data_base[value] = true
  4295.                                     functions:add_to_dump(("%d [table]:"):format(count), indent)
  4296.                                     functions:dump_table(value, indent + 1, index)
  4297.                                 else
  4298.                                     functions:add_to_dump(("%d [table] (Recursive table detected)"):format(count), indent)
  4299.                                 end
  4300.                             else
  4301.                                 functions:add_to_dump(("%d [%s] = %s"):format(count, tostring(typeof(value)), tostring(value)), indent)
  4302.                             end
  4303.                         end
  4304.                     end
  4305.                     function functions:dump_function(input, indent)
  4306.                         functions:add_to_dump(("\nFunction Dump: %s"):format(functions:get_function_name(input)), indent)
  4307.                         functions:add_to_dump(("\nFunction Upvalues: %s"):format(functions:get_function_name(input)), indent)
  4308.                         for index, upvalue in pairs(getupvalues(input)) do
  4309.                             if type(upvalue) == "function" then
  4310.                                 functions:add_to_dump(("%d [function] = %s"):format(index, functions:get_function_name(upvalue)), indent + 1)
  4311.                             elseif type(upvalue) == "table" then
  4312.                                 if not data_base[upvalue] then
  4313.                                     data_base[upvalue] = true
  4314.                                     functions:add_to_dump(("%d [table]:"):format(index), indent + 1)
  4315.                                     functions:dump_table(upvalue, indent + 2, index)
  4316.                                 else
  4317.                                     functions:add_to_dump(("%d [table] (Recursive table detected)"):format(index), indent + 1)
  4318.                                 end
  4319.                             else
  4320.                                 functions:add_to_dump(("%d [%s] = %s"):format(index, tostring(typeof(upvalue)), tostring(upvalue)), indent + 1)
  4321.                             end
  4322.                         end
  4323.                         functions:add_to_dump(("\nFunction Constants: %s"):format(functions:get_function_name(input)), indent)
  4324.                         for index, constant in pairs(getconstants(input)) do
  4325.                             if type(constant) == "function" then
  4326.                                 functions:add_to_dump(("%d [function] = %s"):format(index, functions:get_function_name(constant)), indent + 1)
  4327.                             elseif type(constant) == "table" then
  4328.                                 if not data_base[constant] then
  4329.                                     data_base[constant] = true
  4330.                                     functions:add_to_dump(("%d [table]:"):format(index), indent + 1)
  4331.                                     functions:dump_table(constant, indent + 2, index)
  4332.                                 else
  4333.                                     functions:add_to_dump(("%d [table] (Recursive table detected)"):format(index), indent + 1)
  4334.                                 end
  4335.                             else
  4336.                                 functions:add_to_dump(("%d [%s] = %s"):format(index, tostring(typeof(constant)), tostring(constant)), indent + 1)
  4337.                             end
  4338.                         end
  4339.                     end
  4340.                     for _, _function in pairs(getgc()) do
  4341.                         if typeof(_function) == "function" and getfenv(_function).script and getfenv(_function).script == PreviousScr then
  4342.                             functions:dump_function(_function, 0)
  4343.                             functions:add_to_dump("\n" .. ("="):rep(100), 0, false)
  4344.                         end
  4345.                     end
  4346.                     local source = codeFrame:GetText()
  4347.                     if dump ~= original then source = source .. dump .. "]]" end
  4348.                     codeFrame:SetText(source)
  4349.                 end)
  4350.             end
  4351.         end)
  4352.     end
  4353.  
  4354.     return ScriptViewer
  4355. end
  4356.  
  4357. return {InitDeps = initDeps, InitAfterMain = initAfterMain, Main = main}
  4358. end,
  4359. Lib = function()
  4360. --[[
  4361.     Lib Module
  4362.    
  4363.     Container for functions and classes
  4364. ]]
  4365.  
  4366. -- Common Locals
  4367. local Main,Lib,Apps,Settings -- Main Containers
  4368. local Explorer, Properties, ScriptViewer, Notebook -- Major Apps
  4369. local API,RMD,env,service,plr,create,createSimple -- Main Locals
  4370.  
  4371. local function initDeps(data)
  4372.     Main = data.Main
  4373.     Lib = data.Lib
  4374.     Apps = data.Apps
  4375.     Settings = data.Settings
  4376.  
  4377.     API = data.API
  4378.     RMD = data.RMD
  4379.     env = data.env
  4380.     service = data.service
  4381.     plr = data.plr
  4382.     create = data.create
  4383.     createSimple = data.createSimple
  4384. end
  4385.  
  4386. local function initAfterMain()
  4387.     Explorer = Apps.Explorer
  4388.     Properties = Apps.Properties
  4389.     ScriptViewer = Apps.ScriptViewer
  4390.     Notebook = Apps.Notebook
  4391. end
  4392.  
  4393. local function main()
  4394.     local Lib = {}
  4395.  
  4396.     local renderStepped = service.RunService.RenderStepped
  4397.     local signalWait = renderStepped.wait
  4398.     local PH = newproxy() -- Placeholder, must be replaced in constructor
  4399.     local SIGNAL = newproxy()
  4400.  
  4401.     -- Usually for classes that work with a Roblox Object
  4402.     local function initObj(props,mt)
  4403.         local type = type
  4404.         local function copy(t)
  4405.             local res = {}
  4406.             for i,v in pairs(t) do
  4407.                 if v == SIGNAL then
  4408.                     res[i] = Lib.Signal.new()
  4409.                 elseif type(v) == "table" then
  4410.                     res[i] = copy(v)
  4411.                 else
  4412.                     res[i] = v
  4413.                 end
  4414.             end    
  4415.             return res
  4416.         end
  4417.  
  4418.         local newObj = copy(props)
  4419.         return setmetatable(newObj,mt)
  4420.     end
  4421.  
  4422.     local function getGuiMT(props,funcs)
  4423.         return {__index = function(self,ind) if not props[ind] then return funcs[ind] or self.Gui[ind] end end,
  4424.         __newindex = function(self,ind,val) if not props[ind] then self.Gui[ind] = val else rawset(self,ind,val) end end}
  4425.     end
  4426.  
  4427.     -- Functions
  4428.  
  4429.     Lib.FormatLuaString = (function()
  4430.         local string = string
  4431.         local gsub = string.gsub
  4432.         local format = string.format
  4433.         local char = string.char
  4434.         local cleanTable = {['"'] = '\\"', ['\\'] = '\\\\'}
  4435.         for i = 0,31 do
  4436.             cleanTable[char(i)] = "\\"..format("%03d",i)
  4437.         end
  4438.         for i = 127,255 do
  4439.             cleanTable[char(i)] = "\\"..format("%03d",i)
  4440.         end
  4441.  
  4442.         return function(str)
  4443.             return gsub(str,"[\"\\\0-\31\127-\255]",cleanTable)
  4444.         end
  4445.     end)()
  4446.  
  4447.     Lib.CheckMouseInGui = function(gui)
  4448.         if gui == nil then return false end
  4449.         local mouse = Main.Mouse
  4450.         local guiPosition = gui.AbsolutePosition
  4451.         local guiSize = gui.AbsoluteSize   
  4452.  
  4453.         return mouse.X >= guiPosition.X and mouse.X < guiPosition.X + guiSize.X and mouse.Y >= guiPosition.Y and mouse.Y < guiPosition.Y + guiSize.Y
  4454.     end
  4455.  
  4456.     Lib.IsShiftDown = function()
  4457.         return service.UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) or service.UserInputService:IsKeyDown(Enum.KeyCode.RightShift)
  4458.     end
  4459.  
  4460.     Lib.IsCtrlDown = function()
  4461.         return service.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) or service.UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
  4462.     end
  4463.  
  4464.     Lib.CreateArrow = function(size,num,dir)
  4465.         local max = num
  4466.         local arrowFrame = createSimple("Frame",{
  4467.             BackgroundTransparency = 1,
  4468.             Name = "Arrow",
  4469.             Size = UDim2.new(0,size,0,size)
  4470.         })
  4471.         if dir == "up" then
  4472.             for i = 1,num do
  4473.                 local newLine = createSimple("Frame",{
  4474.                     BackgroundColor3 = Color3.new(220/255,220/255,220/255),
  4475.                     BorderSizePixel = 0,
  4476.                     Position = UDim2.new(0,math.floor(size/2)-(i-1),0,math.floor(size/2)+i-math.floor(max/2)-1),
  4477.                     Size = UDim2.new(0,i+(i-1),0,1),
  4478.                     Parent = arrowFrame
  4479.                 })
  4480.             end
  4481.             return arrowFrame
  4482.         elseif dir == "down" then
  4483.             for i = 1,num do
  4484.                 local newLine = createSimple("Frame",{
  4485.                     BackgroundColor3 = Color3.new(220/255,220/255,220/255),
  4486.                     BorderSizePixel = 0,
  4487.                     Position = UDim2.new(0,math.floor(size/2)-(i-1),0,math.floor(size/2)-i+math.floor(max/2)+1),
  4488.                     Size = UDim2.new(0,i+(i-1),0,1),
  4489.                     Parent = arrowFrame
  4490.                 })
  4491.             end
  4492.             return arrowFrame
  4493.         elseif dir == "left" then
  4494.             for i = 1,num do
  4495.                 local newLine = createSimple("Frame",{
  4496.                     BackgroundColor3 = Color3.new(220/255,220/255,220/255),
  4497.                     BorderSizePixel = 0,
  4498.                     Position = UDim2.new(0,math.floor(size/2)+i-math.floor(max/2)-1,0,math.floor(size/2)-(i-1)),
  4499.                     Size = UDim2.new(0,1,0,i+(i-1)),
  4500.                     Parent = arrowFrame
  4501.                 })
  4502.             end
  4503.             return arrowFrame
  4504.         elseif dir == "right" then
  4505.             for i = 1,num do
  4506.                 local newLine = createSimple("Frame",{
  4507.                     BackgroundColor3 = Color3.new(220/255,220/255,220/255),
  4508.                     BorderSizePixel = 0,
  4509.                     Position = UDim2.new(0,math.floor(size/2)-i+math.floor(max/2)+1,0,math.floor(size/2)-(i-1)),
  4510.                     Size = UDim2.new(0,1,0,i+(i-1)),
  4511.                     Parent = arrowFrame
  4512.                 })
  4513.             end
  4514.             return arrowFrame
  4515.         end
  4516.         error("r u ok")
  4517.     end
  4518.  
  4519.     Lib.ParseXML = (function()
  4520.         local func = function()
  4521.             -- Only exists to parse RMD
  4522.             -- from https://github.com/jonathanpoelen/xmlparser
  4523.  
  4524.             local string, print, pairs = string, print, pairs
  4525.  
  4526.             -- http://lua-users.org/wiki/StringTrim
  4527.             local trim = function(s)
  4528.                 local from = s:match"^%s*()"
  4529.                 return from > #s and "" or s:match(".*%S", from)
  4530.             end
  4531.  
  4532.             local gtchar = string.byte('>', 1)
  4533.             local slashchar = string.byte('/', 1)
  4534.             local D = string.byte('D', 1)
  4535.             local E = string.byte('E', 1)
  4536.  
  4537.             function parse(s, evalEntities)
  4538.                 -- remove comments
  4539.                 s = s:gsub('<!%-%-(.-)%-%->', '')
  4540.  
  4541.                 local entities, tentities = {}
  4542.  
  4543.                 if evalEntities then
  4544.                     local pos = s:find('<[_%w]')
  4545.                     if pos then
  4546.                         s:sub(1, pos):gsub('<!ENTITY%s+([_%w]+)%s+(.)(.-)%2', function(name, q, entity)
  4547.                             entities[#entities+1] = {name=name, value=entity}
  4548.                         end)
  4549.                         tentities = createEntityTable(entities)
  4550.                         s = replaceEntities(s:sub(pos), tentities)
  4551.                     end
  4552.                 end
  4553.  
  4554.                 local t, l = {}, {}
  4555.  
  4556.                 local addtext = function(txt)
  4557.                     txt = txt:match'^%s*(.*%S)' or ''
  4558.                     if #txt ~= 0 then
  4559.                         t[#t+1] = {text=txt}
  4560.                     end    
  4561.                 end
  4562.  
  4563.                 s:gsub('<([?!/]?)([-:_%w]+)%s*(/?>?)([^<]*)', function(type, name, closed, txt)
  4564.                     -- open
  4565.                     if #type == 0 then
  4566.                         local a = {}
  4567.                         if #closed == 0 then
  4568.                             local len = 0
  4569.                             for all,aname,_,value,starttxt in string.gmatch(txt, "(.-([-_%w]+)%s*=%s*(.)(.-)%3%s*(/?>?))") do
  4570.                                 len = len + #all
  4571.                                 a[aname] = value
  4572.                                 if #starttxt ~= 0 then
  4573.                                     txt = txt:sub(len+1)
  4574.                                     closed = starttxt
  4575.                                     break
  4576.                                 end
  4577.                             end
  4578.                         end
  4579.                         t[#t+1] = {tag=name, attrs=a, children={}}
  4580.  
  4581.                         if closed:byte(1) ~= slashchar then
  4582.                             l[#l+1] = t
  4583.                             t = t[#t].children
  4584.                         end
  4585.  
  4586.                         addtext(txt)
  4587.                         -- close
  4588.                     elseif '/' == type then
  4589.                         t = l[#l]
  4590.                         l[#l] = nil
  4591.  
  4592.                         addtext(txt)
  4593.                         -- ENTITY
  4594.                     elseif '!' == type then
  4595.                         if E == name:byte(1) then
  4596.                             txt:gsub('([_%w]+)%s+(.)(.-)%2', function(name, q, entity)
  4597.                                 entities[#entities+1] = {name=name, value=entity}
  4598.                             end, 1)
  4599.                         end
  4600.                         -- elseif '?' == type then
  4601.                         --   print('?  ' .. name .. ' // ' .. attrs .. '$$')
  4602.                         -- elseif '-' == type then
  4603.                         --   print('comment  ' .. name .. ' // ' .. attrs .. '$$')
  4604.                         -- else
  4605.                         --   print('o  ' .. #p .. ' // ' .. name .. ' // ' .. attrs .. '$$')
  4606.                     end
  4607.                 end)
  4608.  
  4609.                 return {children=t, entities=entities, tentities=tentities}
  4610.             end
  4611.  
  4612.             function parseText(txt)
  4613.                 return parse(txt)
  4614.             end
  4615.  
  4616.             function defaultEntityTable()
  4617.                 return { quot='"', apos='\'', lt='<', gt='>', amp='&', tab='\t', nbsp=' ', }
  4618.             end
  4619.  
  4620.             function replaceEntities(s, entities)
  4621.                 return s:gsub('&([^;]+);', entities)
  4622.             end
  4623.  
  4624.             function createEntityTable(docEntities, resultEntities)
  4625.                 entities = resultEntities or defaultEntityTable()
  4626.                 for _,e in pairs(docEntities) do
  4627.                     e.value = replaceEntities(e.value, entities)
  4628.                     entities[e.name] = e.value
  4629.                 end
  4630.                 return entities
  4631.             end
  4632.  
  4633.             return parseText
  4634.         end
  4635.         local newEnv = setmetatable({},{__index = getfenv()})
  4636.         setfenv(func,newEnv)
  4637.         return func()
  4638.     end)()
  4639.  
  4640.     Lib.FastWait = function(s)
  4641.         if not s then return signalWait(renderStepped) end
  4642.         local start = tick()
  4643.         while tick() - start < s do signalWait(renderStepped) end
  4644.     end
  4645.  
  4646.     Lib.ButtonAnim = function(button,data)
  4647.         local holding = false
  4648.         local disabled = false
  4649.         local mode = data and data.Mode or 1
  4650.         local control = {}
  4651.  
  4652.         if mode == 2 then
  4653.             local lerpTo = data.LerpTo or Color3.new(0,0,0)
  4654.             local delta = data.LerpDelta or 0.2
  4655.             control.StartColor = data.StartColor or button.BackgroundColor3
  4656.             control.PressColor = data.PressColor or control.StartColor:lerp(lerpTo,delta)
  4657.             control.HoverColor = data.HoverColor or control.StartColor:lerp(control.PressColor,0.6)
  4658.             control.OutlineColor = data.OutlineColor
  4659.         end
  4660.  
  4661.         button.InputBegan:Connect(function(input)
  4662.             if disabled then return end
  4663.             if input.UserInputType == Enum.UserInputType.MouseMovement and not holding then
  4664.                 if mode == 1 then
  4665.                     button.BackgroundTransparency = 0.4
  4666.                 elseif mode == 2 then
  4667.                     button.BackgroundColor3 = control.HoverColor
  4668.                 end
  4669.             elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  4670.                 holding = true
  4671.                 if mode == 1 then
  4672.                     button.BackgroundTransparency = 0
  4673.                 elseif mode == 2 then
  4674.                     button.BackgroundColor3 = control.PressColor
  4675.                     if control.OutlineColor then button.BorderColor3 = control.PressColor end
  4676.                 end
  4677.             end
  4678.         end)
  4679.  
  4680.         button.InputEnded:Connect(function(input)
  4681.             if disabled then return end
  4682.             if input.UserInputType == Enum.UserInputType.MouseMovement and not holding then
  4683.                 if mode == 1 then
  4684.                     button.BackgroundTransparency = 1
  4685.                 elseif mode == 2 then
  4686.                     button.BackgroundColor3 = control.StartColor
  4687.                 end
  4688.             elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  4689.                 holding = false
  4690.                 if mode == 1 then
  4691.                     button.BackgroundTransparency = Lib.CheckMouseInGui(button) and 0.4 or 1
  4692.                 elseif mode == 2 then
  4693.                     button.BackgroundColor3 = Lib.CheckMouseInGui(button) and control.HoverColor or control.StartColor
  4694.                     if control.OutlineColor then button.BorderColor3 = control.OutlineColor end
  4695.                 end
  4696.             end
  4697.         end)
  4698.  
  4699.         control.Disable = function()
  4700.             disabled = true
  4701.             holding = false
  4702.  
  4703.             if mode == 1 then
  4704.                 button.BackgroundTransparency = 1
  4705.             elseif mode == 2 then
  4706.                 button.BackgroundColor3 = control.StartColor
  4707.             end
  4708.         end
  4709.  
  4710.         control.Enable = function()
  4711.             disabled = false
  4712.         end
  4713.  
  4714.         return control
  4715.     end
  4716.  
  4717.     Lib.FindAndRemove = function(t,item)
  4718.         local pos = table.find(t,item)
  4719.         if pos then table.remove(t,pos) end
  4720.     end
  4721.  
  4722.     Lib.AttachTo = function(obj,data)
  4723.         local target,posOffX,posOffY,sizeOffX,sizeOffY,resize,con
  4724.         local disabled = false
  4725.  
  4726.         local function update()
  4727.             if not obj or not target then return end
  4728.  
  4729.             local targetPos = target.AbsolutePosition
  4730.             local targetSize = target.AbsoluteSize
  4731.             obj.Position = UDim2.new(0,targetPos.X + posOffX,0,targetPos.Y + posOffY)
  4732.             if resize then obj.Size = UDim2.new(0,targetSize.X + sizeOffX,0,targetSize.Y + sizeOffY) end
  4733.         end
  4734.  
  4735.         local function setup(o,data)
  4736.             obj = o
  4737.             data = data or {}
  4738.             target = data.Target
  4739.             posOffX = data.PosOffX or 0
  4740.             posOffY = data.PosOffY or 0
  4741.             sizeOffX = data.SizeOffX or 0
  4742.             sizeOffY = data.SizeOffY or 0
  4743.             resize = data.Resize or false
  4744.  
  4745.             if con then con:Disconnect() con = nil end
  4746.             if target then
  4747.                 con = target.Changed:Connect(function(prop)
  4748.                     if not disabled and prop == "AbsolutePosition" or prop == "AbsoluteSize" then
  4749.                         update()
  4750.                     end
  4751.                 end)
  4752.             end
  4753.  
  4754.             update()
  4755.         end
  4756.         setup(obj,data)
  4757.  
  4758.         return {
  4759.             SetData = function(obj,data)
  4760.                 setup(obj,data)
  4761.             end,
  4762.             Enable = function()
  4763.                 disabled = false
  4764.                 update()
  4765.             end,
  4766.             Disable = function()
  4767.                 disabled = true
  4768.             end,
  4769.             Destroy = function()
  4770.                 con:Disconnect()
  4771.                 con = nil
  4772.             end,
  4773.         }
  4774.     end
  4775.  
  4776.     Lib.ProtectedGuis = {}
  4777.  
  4778.     Lib.ShowGui = function(gui)
  4779.         if env.gethui then
  4780.             gui.Parent = env.gethui()
  4781.         elseif env.protectgui then
  4782.             env.protectgui(gui)
  4783.             gui.Parent = Main.GuiHolder
  4784.         else
  4785.             gui.Parent = Main.GuiHolder
  4786.         end
  4787.     end
  4788.  
  4789.     Lib.ColorToBytes = function(col)
  4790.         local round = math.round
  4791.         return string.format("%d, %d, %d",round(col.r*255),round(col.g*255),round(col.b*255))
  4792.     end
  4793.  
  4794.     Lib.ReadFile = function(filename)
  4795.         if not env.readfile then return end
  4796.  
  4797.         local s,contents = pcall(env.readfile,filename)
  4798.         if s and contents then return contents end
  4799.     end
  4800.  
  4801.     Lib.DeferFunc = function(f,...)
  4802.         signalWait(renderStepped)
  4803.         return f(...)
  4804.     end
  4805.    
  4806.     Lib.LoadCustomAsset = function(filepath)
  4807.         if not env.getcustomasset or not env.isfile or not env.isfile(filepath) then return end
  4808.  
  4809.         return env.getcustomasset(filepath)
  4810.     end
  4811.  
  4812.     Lib.FetchCustomAsset = function(url,filepath)
  4813.         if not env.writefile then return end
  4814.  
  4815.         local s,data = pcall(game["Run Service"].Parent.HttpGet,game["Run Service"].Parent,url)
  4816.         if not s then return end
  4817.  
  4818.         env.writefile(filepath,data)
  4819.         return Lib.LoadCustomAsset(filepath)
  4820.     end
  4821.  
  4822.     -- Classes
  4823.  
  4824.     Lib.Signal = (function()
  4825.         local funcs = {}
  4826.  
  4827.         local disconnect = function(con)
  4828.             local pos = table.find(con.Signal.Connections,con)
  4829.             if pos then table.remove(con.Signal.Connections,pos) end
  4830.         end
  4831.  
  4832.         funcs.Connect = function(self,func)
  4833.             if type(func) ~= "function" then error("Attempt to connect a non-function") end    
  4834.             local con = {
  4835.                 Signal = self,
  4836.                 Func = func,
  4837.                 Disconnect = disconnect
  4838.             }
  4839.             self.Connections[#self.Connections+1] = con
  4840.             return con
  4841.         end
  4842.  
  4843.         funcs.Fire = function(self,...)
  4844.             for i,v in next,self.Connections do
  4845.                 xpcall(coroutine.wrap(v.Func),function(e) warn(e.."\n"..debug.traceback()) end,...)
  4846.             end
  4847.         end
  4848.  
  4849.         local mt = {
  4850.             __index = funcs,
  4851.             __tostring = function(self)
  4852.                 return "Signal: " .. tostring(#self.Connections) .. " Connections"
  4853.             end
  4854.         }
  4855.  
  4856.         local function new()
  4857.             local obj = {}
  4858.             obj.Connections = {}
  4859.  
  4860.             return setmetatable(obj,mt)
  4861.         end
  4862.  
  4863.         return {new = new}
  4864.     end)()
  4865.  
  4866.     Lib.Set = (function()
  4867.         local funcs = {}
  4868.  
  4869.         funcs.Add = function(self,obj)
  4870.             if self.Map[obj] then return end
  4871.  
  4872.             local list = self.List
  4873.             list[#list+1] = obj
  4874.             self.Map[obj] = true
  4875.             self.Changed:Fire()
  4876.         end
  4877.  
  4878.         funcs.AddTable = function(self,t)
  4879.             local changed
  4880.             local list,map = self.List,self.Map
  4881.             for i = 1,#t do
  4882.                 local elem = t[i]
  4883.                 if not map[elem] then
  4884.                     list[#list+1] = elem
  4885.                     map[elem] = true
  4886.                     changed = true
  4887.                 end
  4888.             end
  4889.             if changed then self.Changed:Fire() end
  4890.         end
  4891.  
  4892.         funcs.Remove = function(self,obj)
  4893.             if not self.Map[obj] then return end
  4894.  
  4895.             local list = self.List
  4896.             local pos = table.find(list,obj)
  4897.             if pos then table.remove(list,pos) end
  4898.             self.Map[obj] = nil
  4899.             self.Changed:Fire()
  4900.         end
  4901.  
  4902.         funcs.RemoveTable = function(self,t)
  4903.             local changed
  4904.             local list,map = self.List,self.Map
  4905.             local removeSet = {}
  4906.             for i = 1,#t do
  4907.                 local elem = t[i]
  4908.                 map[elem] = nil
  4909.                 removeSet[elem] = true
  4910.             end
  4911.  
  4912.             for i = #list,1,-1 do
  4913.                 local elem = list[i]
  4914.                 if removeSet[elem] then
  4915.                     table.remove(list,i)
  4916.                     changed = true
  4917.                 end
  4918.             end
  4919.             if changed then self.Changed:Fire() end
  4920.         end
  4921.  
  4922.         funcs.Set = function(self,obj)
  4923.             if #self.List == 1 and self.List[1] == obj then return end
  4924.  
  4925.             self.List = {obj}
  4926.             self.Map = {[obj] = true}
  4927.             self.Changed:Fire()
  4928.         end
  4929.  
  4930.         funcs.SetTable = function(self,t)
  4931.             local newList,newMap = {},{}
  4932.             self.List,self.Map = newList,newMap
  4933.             table.move(t,1,#t,1,newList)
  4934.             for i = 1,#t do
  4935.                 newMap[t[i]] = true
  4936.             end
  4937.             self.Changed:Fire()
  4938.         end
  4939.  
  4940.         funcs.Clear = function(self)
  4941.             if #self.List == 0 then return end
  4942.             self.List = {}
  4943.             self.Map = {}
  4944.             self.Changed:Fire()
  4945.         end
  4946.  
  4947.         local mt = {__index = funcs}
  4948.  
  4949.         local function new()
  4950.             local obj = setmetatable({
  4951.                 List = {},
  4952.                 Map = {},
  4953.                 Changed = Lib.Signal.new()
  4954.             },mt)
  4955.  
  4956.             return obj
  4957.         end
  4958.  
  4959.         return {new = new}
  4960.     end)()
  4961.  
  4962.     Lib.IconMap = (function()
  4963.         local funcs = {}
  4964.  
  4965.         funcs.GetLabel = function(self)
  4966.             local label = Instance.new("ImageLabel")
  4967.             self:SetupLabel(label)
  4968.             return label
  4969.         end
  4970.  
  4971.         funcs.SetupLabel = function(self,obj)
  4972.             obj.BackgroundTransparency = 1
  4973.             obj.ImageRectOffset = Vector2.new(0,0)
  4974.             obj.ImageRectSize = Vector2.new(self.IconSizeX,self.IconSizeY)
  4975.             obj.ScaleType = Enum.ScaleType.Crop
  4976.             obj.Size = UDim2.new(0,self.IconSizeX,0,self.IconSizeY)
  4977.         end
  4978.  
  4979.         funcs.Display = function(self,obj,index)
  4980.             obj.Image = self.MapId
  4981.             if not self.NumX then
  4982.                 obj.ImageRectOffset = Vector2.new(self.IconSizeX*index, 0)
  4983.             else
  4984.                 obj.ImageRectOffset = Vector2.new(self.IconSizeX*(index % self.NumX), self.IconSizeY*math.floor(index / self.NumX))
  4985.             end
  4986.         end
  4987.  
  4988.         funcs.DisplayByKey = function(self,obj,key)
  4989.             if self.IndexDict[key] then
  4990.                 self:Display(obj,self.IndexDict[key])
  4991.             end
  4992.         end
  4993.  
  4994.         funcs.SetDict = function(self,dict)
  4995.             self.IndexDict = dict
  4996.         end
  4997.  
  4998.         local mt = {}
  4999.         mt.__index = funcs
  5000.  
  5001.         local function new(mapId,mapSizeX,mapSizeY,iconSizeX,iconSizeY)
  5002.             local obj = setmetatable({
  5003.                 MapId = mapId,
  5004.                 MapSizeX = mapSizeX,
  5005.                 MapSizeY = mapSizeY,
  5006.                 IconSizeX = iconSizeX,
  5007.                 IconSizeY = iconSizeY,
  5008.                 NumX = mapSizeX/iconSizeX,
  5009.                 IndexDict = {}
  5010.             },mt)
  5011.             return obj
  5012.         end
  5013.  
  5014.         local function newLinear(mapId,iconSizeX,iconSizeY)
  5015.             local obj = setmetatable({
  5016.                 MapId = mapId,
  5017.                 IconSizeX = iconSizeX,
  5018.                 IconSizeY = iconSizeY,
  5019.                 IndexDict = {}
  5020.             },mt)
  5021.             return obj
  5022.         end
  5023.  
  5024.         return {new = new, newLinear = newLinear}
  5025.     end)()
  5026.  
  5027.     Lib.ScrollBar = (function()
  5028.         local funcs = {}
  5029.         local user = service.UserInputService
  5030.         local mouse = plr:GetMouse()
  5031.         local checkMouseInGui = Lib.CheckMouseInGui
  5032.         local createArrow = Lib.CreateArrow
  5033.  
  5034.         local function drawThumb(self)
  5035.             local total = self.TotalSpace
  5036.             local visible = self.VisibleSpace
  5037.             local index = self.Index
  5038.             local scrollThumb = self.GuiElems.ScrollThumb
  5039.             local scrollThumbFrame = self.GuiElems.ScrollThumbFrame
  5040.  
  5041.             if not (self:CanScrollUp()  or self:CanScrollDown()) then
  5042.                 scrollThumb.Visible = false
  5043.             else
  5044.                 scrollThumb.Visible = true
  5045.             end
  5046.  
  5047.             if self.Horizontal then
  5048.                 scrollThumb.Size = UDim2.new(visible/total,0,1,0)
  5049.                 if scrollThumb.AbsoluteSize.X < 16 then
  5050.                     scrollThumb.Size = UDim2.new(0,16,1,0)
  5051.                 end
  5052.                 local fs = scrollThumbFrame.AbsoluteSize.X
  5053.                 local bs = scrollThumb.AbsoluteSize.X
  5054.                 scrollThumb.Position = UDim2.new(self:GetScrollPercent()*(fs-bs)/fs,0,0,0)
  5055.             else
  5056.                 scrollThumb.Size = UDim2.new(1,0,visible/total,0)
  5057.                 if scrollThumb.AbsoluteSize.Y < 16 then
  5058.                     scrollThumb.Size = UDim2.new(1,0,0,16)
  5059.                 end
  5060.                 local fs = scrollThumbFrame.AbsoluteSize.Y
  5061.                 local bs = scrollThumb.AbsoluteSize.Y
  5062.                 scrollThumb.Position = UDim2.new(0,0,self:GetScrollPercent()*(fs-bs)/fs,0)
  5063.             end
  5064.         end
  5065.  
  5066.         local function createFrame(self)
  5067.             local newFrame = createSimple("Frame",{Style=0,Active=true,AnchorPoint=Vector2.new(0,0),BackgroundColor3=Color3.new(0.35294118523598,0.35294118523598,0.35294118523598),BackgroundTransparency=0,BorderColor3=Color3.new(0.10588236153126,0.16470588743687,0.20784315466881),BorderSizePixel=0,ClipsDescendants=false,Draggable=false,Position=UDim2.new(1,-16,0,0),Rotation=0,Selectable=false,Size=UDim2.new(0,16,1,0),SizeConstraint=0,Visible=true,ZIndex=1,Name="ScrollBar",})
  5068.             local button1 = nil
  5069.             local button2 = nil
  5070.  
  5071.             if self.Horizontal then
  5072.                 newFrame.Size = UDim2.new(1,0,0,16)
  5073.                 button1 = createSimple("ImageButton",{
  5074.                     Parent = newFrame,
  5075.                     Name = "Left",
  5076.                     Size = UDim2.new(0,16,0,16),
  5077.                     BackgroundTransparency = 1,
  5078.                     BorderSizePixel = 0,
  5079.                     AutoButtonColor = false
  5080.                 })
  5081.                 createArrow(16,4,"left").Parent = button1
  5082.                 button2 = createSimple("ImageButton",{
  5083.                     Parent = newFrame,
  5084.                     Name = "Right",
  5085.                     Position = UDim2.new(1,-16,0,0),
  5086.                     Size = UDim2.new(0,16,0,16),
  5087.                     BackgroundTransparency = 1,
  5088.                     BorderSizePixel = 0,
  5089.                     AutoButtonColor = false
  5090.                 })
  5091.                 createArrow(16,4,"right").Parent = button2
  5092.             else
  5093.                 newFrame.Size = UDim2.new(0,16,1,0)
  5094.                 button1 = createSimple("ImageButton",{
  5095.                     Parent = newFrame,
  5096.                     Name = "Up",
  5097.                     Size = UDim2.new(0,16,0,16),
  5098.                     BackgroundTransparency = 1,
  5099.                     BorderSizePixel = 0,
  5100.                     AutoButtonColor = false
  5101.                 })
  5102.                 createArrow(16,4,"up").Parent = button1
  5103.                 button2 = createSimple("ImageButton",{
  5104.                     Parent = newFrame,
  5105.                     Name = "Down",
  5106.                     Position = UDim2.new(0,0,1,-16),
  5107.                     Size = UDim2.new(0,16,0,16),
  5108.                     BackgroundTransparency = 1,
  5109.                     BorderSizePixel = 0,
  5110.                     AutoButtonColor = false
  5111.                 })
  5112.                 createArrow(16,4,"down").Parent = button2
  5113.             end
  5114.  
  5115.             local scrollThumbFrame = createSimple("Frame",{
  5116.                 BackgroundTransparency = 1,
  5117.                 Parent = newFrame
  5118.             })
  5119.             if self.Horizontal then
  5120.                 scrollThumbFrame.Position = UDim2.new(0,16,0,0)
  5121.                 scrollThumbFrame.Size = UDim2.new(1,-32,1,0)
  5122.             else
  5123.                 scrollThumbFrame.Position = UDim2.new(0,0,0,16)
  5124.                 scrollThumbFrame.Size = UDim2.new(1,0,1,-32)
  5125.             end
  5126.  
  5127.             local scrollThumb = createSimple("Frame",{
  5128.                 BackgroundColor3 = Color3.new(120/255,120/255,120/255),
  5129.                 BorderSizePixel = 0,
  5130.                 Parent = scrollThumbFrame
  5131.             })
  5132.  
  5133.             local markerFrame = createSimple("Frame",{
  5134.                 BackgroundTransparency = 1,
  5135.                 Name = "Markers",
  5136.                 Size = UDim2.new(1,0,1,0),
  5137.                 Parent = scrollThumbFrame
  5138.             })
  5139.  
  5140.             local buttonPress = false
  5141.             local thumbPress = false
  5142.             local thumbFramePress = false
  5143.  
  5144.             --local thumbColor = Color3.new(120/255,120/255,120/255)
  5145.             --local thumbSelectColor = Color3.new(140/255,140/255,140/255)
  5146.             button1.InputBegan:Connect(function(input)
  5147.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not buttonPress and self:CanScrollUp() then button1.BackgroundTransparency = 0.8 end
  5148.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 or not self:CanScrollUp() then return end
  5149.                 buttonPress = true
  5150.                 button1.BackgroundTransparency = 0.5
  5151.                 if self:CanScrollUp() then self:ScrollUp() self.Scrolled:Fire() end
  5152.                 local buttonTick = tick()
  5153.                 local releaseEvent
  5154.                 releaseEvent = user.InputEnded:Connect(function(input)
  5155.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  5156.                     releaseEvent:Disconnect()
  5157.                     if checkMouseInGui(button1) and self:CanScrollUp() then button1.BackgroundTransparency = 0.8 else button1.BackgroundTransparency = 1 end
  5158.                     buttonPress = false
  5159.                 end)
  5160.                 while buttonPress do
  5161.                     if tick() - buttonTick >= 0.3 and self:CanScrollUp() then
  5162.                         self:ScrollUp()
  5163.                         self.Scrolled:Fire()
  5164.                     end
  5165.                     wait()
  5166.                 end
  5167.             end)
  5168.             button1.InputEnded:Connect(function(input)
  5169.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not buttonPress then button1.BackgroundTransparency = 1 end
  5170.             end)
  5171.             button2.InputBegan:Connect(function(input)
  5172.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not buttonPress and self:CanScrollDown() then button2.BackgroundTransparency = 0.8 end
  5173.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 or not self:CanScrollDown() then return end
  5174.                 buttonPress = true
  5175.                 button2.BackgroundTransparency = 0.5
  5176.                 if self:CanScrollDown() then self:ScrollDown() self.Scrolled:Fire() end
  5177.                 local buttonTick = tick()
  5178.                 local releaseEvent
  5179.                 releaseEvent = user.InputEnded:Connect(function(input)
  5180.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  5181.                     releaseEvent:Disconnect()
  5182.                     if checkMouseInGui(button2) and self:CanScrollDown() then button2.BackgroundTransparency = 0.8 else button2.BackgroundTransparency = 1 end
  5183.                     buttonPress = false
  5184.                 end)
  5185.                 while buttonPress do
  5186.                     if tick() - buttonTick >= 0.3 and self:CanScrollDown() then
  5187.                         self:ScrollDown()
  5188.                         self.Scrolled:Fire()
  5189.                     end
  5190.                     wait()
  5191.                 end
  5192.             end)
  5193.             button2.InputEnded:Connect(function(input)
  5194.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not buttonPress then button2.BackgroundTransparency = 1 end
  5195.             end)
  5196.  
  5197.             scrollThumb.InputBegan:Connect(function(input)
  5198.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not thumbPress then scrollThumb.BackgroundTransparency = 0.2 scrollThumb.BackgroundColor3 = self.ThumbSelectColor end
  5199.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  5200.  
  5201.                 local dir = self.Horizontal and "X" or "Y"
  5202.                 local lastThumbPos = nil
  5203.  
  5204.                 buttonPress = false
  5205.                 thumbFramePress = false        
  5206.                 thumbPress = true
  5207.                 scrollThumb.BackgroundTransparency = 0
  5208.                 local mouseOffset = mouse[dir] - scrollThumb.AbsolutePosition[dir]
  5209.                 local mouseStart = mouse[dir]
  5210.                 local releaseEvent
  5211.                 local mouseEvent
  5212.                 releaseEvent = user.InputEnded:Connect(function(input)
  5213.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  5214.                     releaseEvent:Disconnect()
  5215.                     if mouseEvent then mouseEvent:Disconnect() end
  5216.                     if checkMouseInGui(scrollThumb) then scrollThumb.BackgroundTransparency = 0.2 else scrollThumb.BackgroundTransparency = 0 scrollThumb.BackgroundColor3 = self.ThumbColor end
  5217.                     thumbPress = false
  5218.                 end)
  5219.                 self:Update()
  5220.  
  5221.                 mouseEvent = user.InputChanged:Connect(function(input)
  5222.                     if input.UserInputType == Enum.UserInputType.MouseMovement and thumbPress and releaseEvent.Connected then
  5223.                         local thumbFrameSize = scrollThumbFrame.AbsoluteSize[dir]-scrollThumb.AbsoluteSize[dir]
  5224.                         local pos = mouse[dir] - scrollThumbFrame.AbsolutePosition[dir] - mouseOffset
  5225.                         if pos > thumbFrameSize then
  5226.                             pos = thumbFrameSize
  5227.                         elseif pos < 0 then
  5228.                             pos = 0
  5229.                         end
  5230.                         if lastThumbPos ~= pos then
  5231.                             lastThumbPos = pos
  5232.                             self:ScrollTo(math.floor(0.5+pos/thumbFrameSize*(self.TotalSpace-self.VisibleSpace)))
  5233.                         end
  5234.                         wait()
  5235.                     end
  5236.                 end)
  5237.             end)
  5238.             scrollThumb.InputEnded:Connect(function(input)
  5239.                 if input.UserInputType == Enum.UserInputType.MouseMovement and not thumbPress then scrollThumb.BackgroundTransparency = 0 scrollThumb.BackgroundColor3 = self.ThumbColor end
  5240.             end)
  5241.             scrollThumbFrame.InputBegan:Connect(function(input)
  5242.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 or checkMouseInGui(scrollThumb) then return end
  5243.  
  5244.                 local dir = self.Horizontal and "X" or "Y"
  5245.                 local scrollDir = 0
  5246.                 if mouse[dir] >= scrollThumb.AbsolutePosition[dir] + scrollThumb.AbsoluteSize[dir] then
  5247.                     scrollDir = 1
  5248.                 end
  5249.  
  5250.                 local function doTick()
  5251.                     local scrollSize = self.VisibleSpace - 1
  5252.                     if scrollDir == 0 and mouse[dir] < scrollThumb.AbsolutePosition[dir] then
  5253.                         self:ScrollTo(self.Index - scrollSize)
  5254.                     elseif scrollDir == 1 and mouse[dir] >= scrollThumb.AbsolutePosition[dir] + scrollThumb.AbsoluteSize[dir] then
  5255.                         self:ScrollTo(self.Index + scrollSize)
  5256.                     end
  5257.                 end
  5258.  
  5259.                 thumbPress = false         
  5260.                 thumbFramePress = true
  5261.                 doTick()
  5262.                 local thumbFrameTick = tick()
  5263.                 local releaseEvent
  5264.                 releaseEvent = user.InputEnded:Connect(function(input)
  5265.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  5266.                     releaseEvent:Disconnect()
  5267.                     thumbFramePress = false
  5268.                 end)
  5269.                 while thumbFramePress do
  5270.                     if tick() - thumbFrameTick >= 0.3 and checkMouseInGui(scrollThumbFrame) then
  5271.                         doTick()
  5272.                     end
  5273.                     wait()
  5274.                 end
  5275.             end)
  5276.  
  5277.             newFrame.MouseWheelForward:Connect(function()
  5278.                 self:ScrollTo(self.Index - self.WheelIncrement)
  5279.             end)
  5280.  
  5281.             newFrame.MouseWheelBackward:Connect(function()
  5282.                 self:ScrollTo(self.Index + self.WheelIncrement)
  5283.             end)
  5284.  
  5285.             self.GuiElems.ScrollThumb = scrollThumb
  5286.             self.GuiElems.ScrollThumbFrame = scrollThumbFrame
  5287.             self.GuiElems.Button1 = button1
  5288.             self.GuiElems.Button2 = button2
  5289.             self.GuiElems.MarkerFrame = markerFrame
  5290.  
  5291.             return newFrame
  5292.         end
  5293.  
  5294.         funcs.Update = function(self,nocallback)
  5295.             local total = self.TotalSpace
  5296.             local visible = self.VisibleSpace
  5297.             local index = self.Index
  5298.             local button1 = self.GuiElems.Button1
  5299.             local button2 = self.GuiElems.Button2
  5300.  
  5301.             self.Index = math.clamp(self.Index,0,math.max(0,total-visible))
  5302.  
  5303.             if self.LastTotalSpace ~= self.TotalSpace then
  5304.                 self.LastTotalSpace = self.TotalSpace
  5305.                 self:UpdateMarkers()
  5306.             end
  5307.  
  5308.             if self:CanScrollUp() then
  5309.                 for i,v in pairs(button1.Arrow:GetChildren()) do
  5310.                     v.BackgroundTransparency = 0
  5311.                 end
  5312.             else
  5313.                 button1.BackgroundTransparency = 1
  5314.                 for i,v in pairs(button1.Arrow:GetChildren()) do
  5315.                     v.BackgroundTransparency = 0.5
  5316.                 end
  5317.             end
  5318.             if self:CanScrollDown() then
  5319.                 for i,v in pairs(button2.Arrow:GetChildren()) do
  5320.                     v.BackgroundTransparency = 0
  5321.                 end
  5322.             else
  5323.                 button2.BackgroundTransparency = 1
  5324.                 for i,v in pairs(button2.Arrow:GetChildren()) do
  5325.                     v.BackgroundTransparency = 0.5
  5326.                 end
  5327.             end
  5328.  
  5329.             drawThumb(self)
  5330.         end
  5331.  
  5332.         funcs.UpdateMarkers = function(self)
  5333.             local markerFrame = self.GuiElems.MarkerFrame
  5334.             markerFrame:ClearAllChildren()
  5335.  
  5336.             for i,v in pairs(self.Markers) do
  5337.                 if i < self.TotalSpace then
  5338.                     createSimple("Frame",{
  5339.                         BackgroundTransparency = 0,
  5340.                         BackgroundColor3 = v,
  5341.                         BorderSizePixel = 0,
  5342.                         Position = self.Horizontal and UDim2.new(i/self.TotalSpace,0,1,-6) or UDim2.new(1,-6,i/self.TotalSpace,0),
  5343.                         Size = self.Horizontal and UDim2.new(0,1,0,6) or UDim2.new(0,6,0,1),
  5344.                         Name = "Marker"..tostring(i),
  5345.                         Parent = markerFrame
  5346.                     })
  5347.                 end
  5348.             end
  5349.         end
  5350.  
  5351.         funcs.AddMarker = function(self,ind,color)
  5352.             self.Markers[ind] = color or Color3.new(0,0,0)
  5353.         end
  5354.         funcs.ScrollTo = function(self,ind,nocallback)
  5355.             self.Index = ind
  5356.             self:Update()
  5357.             if not nocallback then
  5358.                 self.Scrolled:Fire()
  5359.             end
  5360.         end
  5361.         funcs.ScrollUp = function(self)
  5362.             self.Index = self.Index - self.Increment
  5363.             self:Update()
  5364.         end
  5365.         funcs.ScrollDown = function(self)
  5366.             self.Index = self.Index + self.Increment
  5367.             self:Update()
  5368.         end
  5369.         funcs.CanScrollUp = function(self)
  5370.             return self.Index > 0
  5371.         end
  5372.         funcs.CanScrollDown = function(self)
  5373.             return self.Index + self.VisibleSpace < self.TotalSpace
  5374.         end
  5375.         funcs.GetScrollPercent = function(self)
  5376.             return self.Index/(self.TotalSpace-self.VisibleSpace)
  5377.         end
  5378.         funcs.SetScrollPercent = function(self,perc)
  5379.             self.Index = math.floor(perc*(self.TotalSpace-self.VisibleSpace))
  5380.             self:Update()
  5381.         end
  5382.  
  5383.         funcs.Texture = function(self,data)
  5384.             self.ThumbColor = data.ThumbColor or Color3.new(0,0,0)
  5385.             self.ThumbSelectColor = data.ThumbSelectColor or Color3.new(0,0,0)
  5386.             self.GuiElems.ScrollThumb.BackgroundColor3 = data.ThumbColor or Color3.new(0,0,0)
  5387.             self.Gui.BackgroundColor3 = data.FrameColor or Color3.new(0,0,0)
  5388.             self.GuiElems.Button1.BackgroundColor3 = data.ButtonColor or Color3.new(0,0,0)
  5389.             self.GuiElems.Button2.BackgroundColor3 = data.ButtonColor or Color3.new(0,0,0)
  5390.             for i,v in pairs(self.GuiElems.Button1.Arrow:GetChildren()) do
  5391.                 v.BackgroundColor3 = data.ArrowColor or Color3.new(0,0,0)
  5392.             end
  5393.             for i,v in pairs(self.GuiElems.Button2.Arrow:GetChildren()) do
  5394.                 v.BackgroundColor3 = data.ArrowColor or Color3.new(0,0,0)
  5395.             end
  5396.         end
  5397.  
  5398.         funcs.SetScrollFrame = function(self,frame)
  5399.             if self.ScrollUpEvent then self.ScrollUpEvent:Disconnect() self.ScrollUpEvent = nil end
  5400.             if self.ScrollDownEvent then self.ScrollDownEvent:Disconnect() self.ScrollDownEvent = nil end
  5401.             self.ScrollUpEvent = frame.MouseWheelForward:Connect(function() self:ScrollTo(self.Index - self.WheelIncrement) end)
  5402.             self.ScrollDownEvent = frame.MouseWheelBackward:Connect(function() self:ScrollTo(self.Index + self.WheelIncrement) end)
  5403.         end
  5404.  
  5405.         local mt = {}
  5406.         mt.__index = funcs
  5407.  
  5408.         local function new(hor)
  5409.             local obj = setmetatable({
  5410.                 Index = 0,
  5411.                 VisibleSpace = 0,
  5412.                 TotalSpace = 0,
  5413.                 Increment = 1,
  5414.                 WheelIncrement = 1,
  5415.                 Markers = {},
  5416.                 GuiElems = {},
  5417.                 Horizontal = hor,
  5418.                 LastTotalSpace = 0,
  5419.                 Scrolled = Lib.Signal.new()
  5420.             },mt)
  5421.             obj.Gui = createFrame(obj)
  5422.             obj:Texture({
  5423.                 ThumbColor = Color3.fromRGB(60,60,60),
  5424.                 ThumbSelectColor = Color3.fromRGB(75,75,75),
  5425.                 ArrowColor = Color3.new(1,1,1),
  5426.                 FrameColor = Color3.fromRGB(40,40,40),
  5427.                 ButtonColor = Color3.fromRGB(75,75,75)
  5428.             })
  5429.             return obj
  5430.         end
  5431.  
  5432.         return {new = new}
  5433.     end)()
  5434.  
  5435.     Lib.Window = (function()
  5436.         local funcs = {}
  5437.         local static = {MinWidth = 200, FreeWidth = 200}
  5438.         local mouse = plr:GetMouse()
  5439.         local sidesGui,alignIndicator
  5440.         local visibleWindows = {}
  5441.         local leftSide = {Width = 300, Windows = {}, ResizeCons = {}, Hidden = true}
  5442.         local rightSide = {Width = 300, Windows = {}, ResizeCons = {}, Hidden = true}
  5443.  
  5444.         local displayOrderStart
  5445.         local sideDisplayOrder
  5446.         local sideTweenInfo = TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  5447.         local tweens = {}
  5448.         local isA = game["Run Service"].Parent.IsA
  5449.  
  5450.         local theme = {
  5451.             MainColor1 = Color3.fromRGB(52,52,52),
  5452.             MainColor2 = Color3.fromRGB(45,45,45),
  5453.             Button = Color3.fromRGB(60,60,60)
  5454.         }
  5455.  
  5456.         local function stopTweens()
  5457.             for i = 1,#tweens do
  5458.                 tweens[i]:Cancel()
  5459.             end
  5460.             tweens = {}
  5461.         end
  5462.  
  5463.         local function resizeHook(self,resizer,dir)
  5464.             local guiMain = self.GuiElems.Main
  5465.             resizer.InputBegan:Connect(function(input)
  5466.                 if not self.Dragging and not self.Resizing and self.Resizable and self.ResizableInternal then
  5467.                     local isH = dir:find("[WE]") and true
  5468.                     local isV = dir:find("[NS]") and true
  5469.                     local signX = dir:find("W",1,true) and -1 or 1
  5470.                     local signY = dir:find("N",1,true) and -1 or 1
  5471.  
  5472.                     if self.Minimized and isV then return end
  5473.  
  5474.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  5475.                         resizer.BackgroundTransparency = 0.5
  5476.                     elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  5477.                         local releaseEvent,mouseEvent
  5478.  
  5479.                         local offX = mouse.X - resizer.AbsolutePosition.X
  5480.                         local offY = mouse.Y - resizer.AbsolutePosition.Y
  5481.  
  5482.                         self.Resizing = resizer
  5483.                         resizer.BackgroundTransparency = 1
  5484.  
  5485.                         releaseEvent = service.UserInputService.InputEnded:Connect(function(input)
  5486.                             if input.UserInputType == Enum.UserInputType.MouseButton1 then
  5487.                                 releaseEvent:Disconnect()
  5488.                                 mouseEvent:Disconnect()
  5489.                                 self.Resizing = false
  5490.                                 resizer.BackgroundTransparency = 1
  5491.                             end
  5492.                         end)
  5493.  
  5494.                         mouseEvent = service.UserInputService.InputChanged:Connect(function(input)
  5495.                             if self.Resizable and self.ResizableInternal and input.UserInputType == Enum.UserInputType.MouseMovement then
  5496.                                 self:StopTweens()
  5497.                                 local deltaX = input.Position.X - resizer.AbsolutePosition.X - offX
  5498.                                 local deltaY = input.Position.Y - resizer.AbsolutePosition.Y - offY
  5499.  
  5500.                                 if guiMain.AbsoluteSize.X + deltaX*signX < self.MinX then deltaX = signX*(self.MinX - guiMain.AbsoluteSize.X) end
  5501.                                 if guiMain.AbsoluteSize.Y + deltaY*signY < self.MinY then deltaY = signY*(self.MinY - guiMain.AbsoluteSize.Y) end
  5502.                                 if signY < 0 and guiMain.AbsolutePosition.Y + deltaY < 0 then deltaY = -guiMain.AbsolutePosition.Y end
  5503.  
  5504.                                 guiMain.Position = guiMain.Position + UDim2.new(0,(signX < 0 and deltaX or 0),0,(signY < 0 and deltaY or 0))
  5505.                                 self.SizeX = self.SizeX + (isH and deltaX*signX or 0)
  5506.                                 self.SizeY = self.SizeY + (isV and deltaY*signY or 0)
  5507.                                 guiMain.Size = UDim2.new(0,self.SizeX,0,self.Minimized and 20 or self.SizeY)
  5508.  
  5509.                                 --if isH then self.SizeX = guiMain.AbsoluteSize.X end
  5510.                                 --if isV then self.SizeY = guiMain.AbsoluteSize.Y end
  5511.                             end
  5512.                         end)
  5513.                     end
  5514.                 end
  5515.             end)
  5516.  
  5517.             resizer.InputEnded:Connect(function(input)
  5518.                 if input.UserInputType == Enum.UserInputType.MouseMovement and self.Resizing ~= resizer then
  5519.                     resizer.BackgroundTransparency = 1
  5520.                 end
  5521.             end)
  5522.         end
  5523.  
  5524.         local updateWindows
  5525.  
  5526.         local function moveToTop(window)
  5527.             local found = table.find(visibleWindows,window)
  5528.             if found then
  5529.                 table.remove(visibleWindows,found)
  5530.                 table.insert(visibleWindows,1,window)
  5531.                 updateWindows()
  5532.             end
  5533.         end
  5534.  
  5535.         local function sideHasRoom(side,neededSize)
  5536.             local maxY = sidesGui.AbsoluteSize.Y - (math.max(0,#side.Windows - 1) * 4)
  5537.             local inc = 0
  5538.             for i,v in pairs(side.Windows) do
  5539.                 inc = inc + (v.MinY or 100)
  5540.                 if inc > maxY - neededSize then return false end
  5541.             end
  5542.  
  5543.             return true
  5544.         end
  5545.  
  5546.         local function getSideInsertPos(side,curY)
  5547.             local pos = #side.Windows + 1
  5548.             local range = {0,sidesGui.AbsoluteSize.Y}
  5549.  
  5550.             for i,v in pairs(side.Windows) do
  5551.                 local midPos = v.PosY + v.SizeY/2
  5552.                 if curY <= midPos then
  5553.                     pos = i
  5554.                     range[2] = midPos
  5555.                     break
  5556.                 else
  5557.                     range[1] = midPos
  5558.                 end
  5559.             end
  5560.  
  5561.             return pos,range
  5562.         end
  5563.  
  5564.         local function focusInput(self,obj)
  5565.             if isA(obj,"GuiButton") then
  5566.                 obj.MouseButton1Down:Connect(function()
  5567.                     moveToTop(self)
  5568.                 end)
  5569.             elseif isA(obj,"TextBox") then
  5570.                 obj.Focused:Connect(function()
  5571.                     moveToTop(self)
  5572.                 end)
  5573.             end
  5574.         end
  5575.  
  5576.         local createGui = function(self)
  5577.             local gui = create({
  5578.                 {1,"ScreenGui",{Name="Window",}},
  5579.                 {2,"Frame",{Active=true,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="Main",Parent={1},Position=UDim2.new(0.40000000596046,0,0.40000000596046,0),Size=UDim2.new(0,300,0,300),}},
  5580.                 {3,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,Name="Content",Parent={2},Position=UDim2.new(0,0,0,20),Size=UDim2.new(1,0,1,-20),ClipsDescendants=true}},
  5581.                 {4,"Frame",{BackgroundColor3=Color3.fromRGB(33,33,33),BorderSizePixel=0,Name="Line",Parent={3},Size=UDim2.new(1,0,0,1),}},
  5582.                 {5,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="TopBar",Parent={2},Size=UDim2.new(1,0,0,20),}},
  5583.                 {6,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={5},Position=UDim2.new(0,5,0,0),Size=UDim2.new(1,-10,0,20),Text="Window",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,}},
  5584.                 {7,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Close",Parent={5},Position=UDim2.new(1,-18,0,2),Size=UDim2.new(0,16,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  5585.                 {8,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5054663650",Parent={7},Position=UDim2.new(0,3,0,3),Size=UDim2.new(0,10,0,10),}},
  5586.                 {9,"UICorner",{CornerRadius=UDim.new(0,4),Parent={7},}},
  5587.                 {10,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Minimize",Parent={5},Position=UDim2.new(1,-36,0,2),Size=UDim2.new(0,16,0,16),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  5588.                 {11,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://5034768003",Parent={10},Position=UDim2.new(0,3,0,3),Size=UDim2.new(0,10,0,10),}},
  5589.                 {12,"UICorner",{CornerRadius=UDim.new(0,4),Parent={10},}},
  5590.                 {13,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Image="rbxassetid://1427967925",Name="Outlines",Parent={2},Position=UDim2.new(0,-5,0,-5),ScaleType=1,Size=UDim2.new(1,10,1,10),SliceCenter=Rect.new(6,6,25,25),TileSize=UDim2.new(0,20,0,20),}},
  5591.                 {14,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="ResizeControls",Parent={2},Position=UDim2.new(0,-5,0,-5),Size=UDim2.new(1,10,1,10),}},
  5592.                 {15,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="North",Parent={14},Position=UDim2.new(0,5,0,0),Size=UDim2.new(1,-10,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5593.                 {16,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="South",Parent={14},Position=UDim2.new(0,5,1,-5),Size=UDim2.new(1,-10,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5594.                 {17,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="NorthEast",Parent={14},Position=UDim2.new(1,-5,0,0),Size=UDim2.new(0,5,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5595.                 {18,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="East",Parent={14},Position=UDim2.new(1,-5,0,5),Size=UDim2.new(0,5,1,-10),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5596.                 {19,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="West",Parent={14},Position=UDim2.new(0,0,0,5),Size=UDim2.new(0,5,1,-10),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5597.                 {20,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="SouthEast",Parent={14},Position=UDim2.new(1,-5,1,-5),Size=UDim2.new(0,5,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5598.                 {21,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="NorthWest",Parent={14},Size=UDim2.new(0,5,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5599.                 {22,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.27450981736183,0.27450981736183,0.27450981736183),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="SouthWest",Parent={14},Position=UDim2.new(0,0,1,-5),Size=UDim2.new(0,5,0,5),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  5600.             })
  5601.  
  5602.             local guiMain = gui.Main
  5603.             local guiTopBar = guiMain.TopBar
  5604.             local guiResizeControls = guiMain.ResizeControls
  5605.  
  5606.             self.GuiElems.Main = guiMain
  5607.             self.GuiElems.TopBar = guiMain.TopBar
  5608.             self.GuiElems.Content = guiMain.Content
  5609.             self.GuiElems.Line = guiMain.Content.Line
  5610.             self.GuiElems.Outlines = guiMain.Outlines
  5611.             self.GuiElems.Title = guiTopBar.Title
  5612.             self.GuiElems.Close = guiTopBar.Close
  5613.             self.GuiElems.Minimize = guiTopBar.Minimize
  5614.             self.GuiElems.ResizeControls = guiResizeControls
  5615.             self.ContentPane = guiMain.Content
  5616.  
  5617.             guiTopBar.InputBegan:Connect(function(input)
  5618.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and self.Draggable then
  5619.                     local releaseEvent,mouseEvent
  5620.  
  5621.                     local maxX = sidesGui.AbsoluteSize.X
  5622.                     local initX = guiMain.AbsolutePosition.X
  5623.                     local initY = guiMain.AbsolutePosition.Y
  5624.                     local offX = mouse.X - initX
  5625.                     local offY = mouse.Y - initY
  5626.  
  5627.                     local alignInsertPos,alignInsertSide
  5628.  
  5629.                     guiDragging = true
  5630.  
  5631.                     releaseEvent = cloneref(game["Run Service"].Parent:GetService("UserInputService")).InputEnded:Connect(function(input)
  5632.                         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  5633.                             releaseEvent:Disconnect()
  5634.                             mouseEvent:Disconnect()
  5635.                             guiDragging = false
  5636.                             alignIndicator.Parent = nil
  5637.                             if alignInsertSide then
  5638.                                 local targetSide = (alignInsertSide == "left" and leftSide) or (alignInsertSide == "right" and rightSide)
  5639.                                 self:AlignTo(targetSide,alignInsertPos)
  5640.                             end
  5641.                         end
  5642.                     end)
  5643.  
  5644.                     mouseEvent = cloneref(game["Run Service"].Parent:GetService("UserInputService")).InputChanged:Connect(function(input)
  5645.                         if input.UserInputType == Enum.UserInputType.MouseMovement and self.Draggable and not self.Closed then
  5646.                             if self.Aligned then
  5647.                                 if leftSide.Resizing or rightSide.Resizing then return end
  5648.                                 local posX,posY = input.Position.X-offX,input.Position.Y-offY
  5649.                                 local delta = math.sqrt((posX-initX)^2 + (posY-initY)^2)
  5650.                                 if delta >= 5 then
  5651.                                     self:SetAligned(false)
  5652.                                 end
  5653.                             else
  5654.                                 local inputX,inputY = input.Position.X,input.Position.Y
  5655.                                 local posX,posY = inputX-offX,inputY-offY
  5656.                                 if posY < 0 then posY = 0 end
  5657.                                 guiMain.Position = UDim2.new(0,posX,0,posY)
  5658.  
  5659.                                 if self.Resizable and self.Alignable then
  5660.                                     if inputX < 25 then
  5661.                                         if sideHasRoom(leftSide,self.MinY or 100) then
  5662.                                             local insertPos,range = getSideInsertPos(leftSide,inputY)
  5663.                                             alignIndicator.Indicator.Position = UDim2.new(0,-15,0,range[1])
  5664.                                             alignIndicator.Indicator.Size = UDim2.new(0,40,0,range[2]-range[1])
  5665.                                             Lib.ShowGui(alignIndicator)
  5666.                                             alignInsertPos = insertPos
  5667.                                             alignInsertSide = "left"
  5668.                                             return
  5669.                                         end
  5670.                                     elseif inputX >= maxX - 25 then
  5671.                                         if sideHasRoom(rightSide,self.MinY or 100) then
  5672.                                             local insertPos,range = getSideInsertPos(rightSide,inputY)
  5673.                                             alignIndicator.Indicator.Position = UDim2.new(0,maxX-25,0,range[1])
  5674.                                             alignIndicator.Indicator.Size = UDim2.new(0,40,0,range[2]-range[1])
  5675.                                             Lib.ShowGui(alignIndicator)
  5676.                                             alignInsertPos = insertPos
  5677.                                             alignInsertSide = "right"
  5678.                                             return
  5679.                                         end
  5680.                                     end
  5681.                                 end
  5682.                                 alignIndicator.Parent = nil
  5683.                                 alignInsertPos = nil
  5684.                                 alignInsertSide = nil
  5685.                             end
  5686.                         end
  5687.                     end)
  5688.                 end
  5689.             end)
  5690.  
  5691.             guiTopBar.Close.MouseButton1Click:Connect(function()
  5692.                 if self.Closed then return end
  5693.                 self:Close()
  5694.             end)
  5695.  
  5696.             guiTopBar.Minimize.MouseButton1Click:Connect(function()
  5697.                 if self.Closed then return end
  5698.                 if self.Aligned then
  5699.                     self:SetAligned(false)
  5700.                 else
  5701.                     self:SetMinimized()
  5702.                 end
  5703.             end)
  5704.  
  5705.             guiTopBar.Minimize.MouseButton2Click:Connect(function()
  5706.                 if self.Closed then return end
  5707.                 if not self.Aligned then
  5708.                     self:SetMinimized(nil,2)
  5709.                     guiTopBar.Minimize.BackgroundTransparency = 1
  5710.                 end
  5711.             end)
  5712.  
  5713.             guiMain.InputBegan:Connect(function(input)
  5714.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and not self.Aligned and not self.Closed then
  5715.                     moveToTop(self)
  5716.                 end
  5717.             end)
  5718.  
  5719.             guiMain:GetPropertyChangedSignal("AbsolutePosition"):Connect(function()
  5720.                 local absPos = guiMain.AbsolutePosition
  5721.                 self.PosX = absPos.X
  5722.                 self.PosY = absPos.Y
  5723.             end)
  5724.  
  5725.             resizeHook(self,guiResizeControls.North,"N")
  5726.             resizeHook(self,guiResizeControls.NorthEast,"NE")
  5727.             resizeHook(self,guiResizeControls.East,"E")
  5728.             resizeHook(self,guiResizeControls.SouthEast,"SE")
  5729.             resizeHook(self,guiResizeControls.South,"S")
  5730.             resizeHook(self,guiResizeControls.SouthWest,"SW")
  5731.             resizeHook(self,guiResizeControls.West,"W")
  5732.             resizeHook(self,guiResizeControls.NorthWest,"NW")
  5733.  
  5734.             guiMain.Size = UDim2.new(0,self.SizeX,0,self.SizeY)
  5735.  
  5736.             gui.DescendantAdded:Connect(function(obj) focusInput(self,obj) end)
  5737.             local descs = gui:GetDescendants()
  5738.             for i = 1,#descs do
  5739.                 focusInput(self,descs[i])
  5740.             end
  5741.  
  5742.             self.MinimizeAnim = Lib.ButtonAnim(guiTopBar.Minimize)
  5743.             self.CloseAnim = Lib.ButtonAnim(guiTopBar.Close)
  5744.  
  5745.             return gui
  5746.         end
  5747.  
  5748.         local function updateSideFrames(noTween)
  5749.             stopTweens()
  5750.             leftSide.Frame.Size = UDim2.new(0,leftSide.Width,1,0)
  5751.             rightSide.Frame.Size = UDim2.new(0,rightSide.Width,1,0)
  5752.             leftSide.Frame.Resizer.Position = UDim2.new(0,leftSide.Width,0,0)
  5753.             rightSide.Frame.Resizer.Position = UDim2.new(0,-5,0,0)
  5754.  
  5755.             --leftSide.Frame.Visible = (#leftSide.Windows > 0)
  5756.             --rightSide.Frame.Visible = (#rightSide.Windows > 0)
  5757.  
  5758.             --[[if #leftSide.Windows > 0 and leftSide.Frame.Position == UDim2.new(0,-leftSide.Width-5,0,0) then
  5759.                 leftSide.Frame:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)
  5760.             elseif #leftSide.Windows == 0 and leftSide.Frame.Position == UDim2.new(0,0,0,0) then
  5761.                 leftSide.Frame:TweenPosition(UDim2.new(0,-leftSide.Width-5,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)
  5762.             end
  5763.             local rightTweenPos = (#rightSide.Windows == 0 and UDim2.new(1,5,0,0) or UDim2.new(1,-rightSide.Width,0,0))
  5764.             rightSide.Frame:TweenPosition(rightTweenPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)]]
  5765.             local leftHidden = #leftSide.Windows == 0 or leftSide.Hidden
  5766.             local rightHidden = #rightSide.Windows == 0 or rightSide.Hidden
  5767.             local leftPos = (leftHidden and UDim2.new(0,-leftSide.Width-10,0,0) or UDim2.new(0,0,0,0))
  5768.             local rightPos = (rightHidden and UDim2.new(1,10,0,0) or UDim2.new(1,-rightSide.Width,0,0))
  5769.  
  5770.             sidesGui.LeftToggle.Text = leftHidden and ">" or "<"
  5771.             sidesGui.RightToggle.Text = rightHidden and "<" or ">"
  5772.  
  5773.             if not noTween then
  5774.                 local function insertTween(...)
  5775.                     local tween = service.TweenService:Create(...)
  5776.                     tweens[#tweens+1] = tween
  5777.                     tween:Play()
  5778.                 end
  5779.                 insertTween(leftSide.Frame,sideTweenInfo,{Position = leftPos})
  5780.                 insertTween(rightSide.Frame,sideTweenInfo,{Position = rightPos})
  5781.                 insertTween(sidesGui.LeftToggle,sideTweenInfo,{Position = UDim2.new(0,#leftSide.Windows == 0 and -16 or 0,0,-36)})
  5782.                 insertTween(sidesGui.RightToggle,sideTweenInfo,{Position = UDim2.new(1,#rightSide.Windows == 0 and 0 or -16,0,-36)})
  5783.             else
  5784.                 leftSide.Frame.Position = leftPos
  5785.                 rightSide.Frame.Position = rightPos
  5786.                 sidesGui.LeftToggle.Position = UDim2.new(0,#leftSide.Windows == 0 and -16 or 0,0,-36)
  5787.                 sidesGui.RightToggle.Position = UDim2.new(1,#rightSide.Windows == 0 and 0 or -16,0,-36)
  5788.             end
  5789.         end
  5790.  
  5791.         local function getSideFramePos(side)
  5792.             local leftHidden = #leftSide.Windows == 0 or leftSide.Hidden
  5793.             local rightHidden = #rightSide.Windows == 0 or rightSide.Hidden
  5794.             if side == leftSide then
  5795.                 return (leftHidden and UDim2.new(0,-leftSide.Width-10,0,0) or UDim2.new(0,0,0,0))
  5796.             else
  5797.                 return (rightHidden and UDim2.new(1,10,0,0) or UDim2.new(1,-rightSide.Width,0,0))
  5798.             end
  5799.         end
  5800.  
  5801.         local function sideResized(side)
  5802.             local currentPos = 0
  5803.             local sideFramePos = getSideFramePos(side)
  5804.             for i,v in pairs(side.Windows) do
  5805.                 v.SizeX = side.Width
  5806.                 v.GuiElems.Main.Size = UDim2.new(0,side.Width,0,v.SizeY)
  5807.                 v.GuiElems.Main.Position = UDim2.new(sideFramePos.X.Scale,sideFramePos.X.Offset,0,currentPos)
  5808.                 currentPos = currentPos + v.SizeY+4
  5809.             end
  5810.         end
  5811.  
  5812.         local function sideResizerHook(resizer,dir,side,pos)
  5813.             local mouse = Main.Mouse
  5814.             local windows = side.Windows
  5815.  
  5816.             resizer.InputBegan:Connect(function(input)
  5817.                 if not side.Resizing then
  5818.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  5819.                         resizer.BackgroundColor3 = theme.MainColor2
  5820.                     elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  5821.                         local releaseEvent,mouseEvent
  5822.  
  5823.                         local offX = mouse.X - resizer.AbsolutePosition.X
  5824.                         local offY = mouse.Y - resizer.AbsolutePosition.Y
  5825.  
  5826.                         side.Resizing = resizer
  5827.                         resizer.BackgroundColor3 = theme.MainColor2
  5828.  
  5829.                         releaseEvent = service.UserInputService.InputEnded:Connect(function(input)
  5830.                             if input.UserInputType == Enum.UserInputType.MouseButton1 then
  5831.                                 releaseEvent:Disconnect()
  5832.                                 mouseEvent:Disconnect()
  5833.                                 side.Resizing = false
  5834.                                 resizer.BackgroundColor3 = theme.Button
  5835.                             end
  5836.                         end)
  5837.  
  5838.                         mouseEvent = service.UserInputService.InputChanged:Connect(function(input)
  5839.                             if not resizer.Parent then
  5840.                                 releaseEvent:Disconnect()
  5841.                                 mouseEvent:Disconnect()
  5842.                                 side.Resizing = false
  5843.                                 return
  5844.                             end
  5845.                             if input.UserInputType == Enum.UserInputType.MouseMovement then
  5846.                                 if dir == "V" then
  5847.                                     local delta = input.Position.Y - resizer.AbsolutePosition.Y - offY
  5848.  
  5849.                                     if delta > 0 then
  5850.                                         local neededSize = delta
  5851.                                         for i = pos+1,#windows do
  5852.                                             local window = windows[i]
  5853.                                             local newSize = math.max(window.SizeY-neededSize,(window.MinY or 100))
  5854.                                             neededSize = neededSize - (window.SizeY - newSize)
  5855.                                             window.SizeY = newSize
  5856.                                         end
  5857.                                         windows[pos].SizeY = windows[pos].SizeY + math.max(0,delta-neededSize)
  5858.                                     else
  5859.                                         local neededSize = -delta
  5860.                                         for i = pos,1,-1 do
  5861.                                             local window = windows[i]
  5862.                                             local newSize = math.max(window.SizeY-neededSize,(window.MinY or 100))
  5863.                                             neededSize = neededSize - (window.SizeY - newSize)
  5864.                                             window.SizeY = newSize
  5865.                                         end
  5866.                                         windows[pos+1].SizeY = windows[pos+1].SizeY + math.max(0,-delta-neededSize)
  5867.                                     end
  5868.  
  5869.                                     updateSideFrames()
  5870.                                     sideResized(side)
  5871.                                 elseif dir == "H" then
  5872.                                     local maxWidth = math.max(300,sidesGui.AbsoluteSize.X-static.FreeWidth)
  5873.                                     local otherSide = (side == leftSide and rightSide or leftSide)
  5874.                                     local delta = input.Position.X - resizer.AbsolutePosition.X - offX
  5875.                                     delta = (side == leftSide and delta or -delta)
  5876.  
  5877.                                     local proposedSize = math.max(static.MinWidth,side.Width + delta)
  5878.                                     if proposedSize + otherSide.Width <= maxWidth then
  5879.                                         side.Width = proposedSize
  5880.                                     else
  5881.                                         local newOtherSize = maxWidth - proposedSize
  5882.                                         if newOtherSize >= static.MinWidth then
  5883.                                             side.Width = proposedSize
  5884.                                             otherSide.Width = newOtherSize
  5885.                                         else
  5886.                                             side.Width = maxWidth - static.MinWidth
  5887.                                             otherSide.Width = static.MinWidth
  5888.                                         end
  5889.                                     end
  5890.  
  5891.                                     updateSideFrames(true)
  5892.                                     sideResized(side)
  5893.                                     sideResized(otherSide)
  5894.                                 end
  5895.                             end
  5896.                         end)
  5897.                     end
  5898.                 end
  5899.             end)
  5900.  
  5901.             resizer.InputEnded:Connect(function(input)
  5902.                 if input.UserInputType == Enum.UserInputType.MouseMovement and side.Resizing ~= resizer then
  5903.                     resizer.BackgroundColor3 = theme.Button
  5904.                 end
  5905.             end)
  5906.         end
  5907.  
  5908.         local function renderSide(side,noTween) -- TODO: Use existing resizers
  5909.             local currentPos = 0
  5910.             local sideFramePos = getSideFramePos(side)
  5911.             local template = side.WindowResizer:Clone()
  5912.             for i,v in pairs(side.ResizeCons) do v:Disconnect() end
  5913.             for i,v in pairs(side.Frame:GetChildren()) do if v.Name == "WindowResizer" then v:Destroy() end end
  5914.             side.ResizeCons = {}
  5915.             side.Resizing = nil
  5916.  
  5917.             for i,v in pairs(side.Windows) do
  5918.                 v.SidePos = i
  5919.                 local isEnd = i == #side.Windows
  5920.                 local size = UDim2.new(0,side.Width,0,v.SizeY)
  5921.                 local pos = UDim2.new(sideFramePos.X.Scale,sideFramePos.X.Offset,0,currentPos)
  5922.                 Lib.ShowGui(v.Gui)
  5923.                 --v.GuiElems.Main:TweenSizeAndPosition(size,pos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)
  5924.                 if noTween then
  5925.                     v.GuiElems.Main.Size = size
  5926.                     v.GuiElems.Main.Position = pos
  5927.                 else
  5928.                     local tween = service.TweenService:Create(v.GuiElems.Main,sideTweenInfo,{Size = size, Position = pos})
  5929.                     tweens[#tweens+1] = tween
  5930.                     tween:Play()
  5931.                 end
  5932.                 currentPos = currentPos + v.SizeY+4
  5933.  
  5934.                 if not isEnd then
  5935.                     local newTemplate = template:Clone()
  5936.                     newTemplate.Position = UDim2.new(1,-side.Width,0,currentPos-4)
  5937.                     side.ResizeCons[#side.ResizeCons+1] = v.Gui.Main:GetPropertyChangedSignal("Size"):Connect(function()
  5938.                         newTemplate.Position = UDim2.new(1,-side.Width,0, v.GuiElems.Main.Position.Y.Offset + v.GuiElems.Main.Size.Y.Offset)
  5939.                     end)
  5940.                     side.ResizeCons[#side.ResizeCons+1] = v.Gui.Main:GetPropertyChangedSignal("Position"):Connect(function()
  5941.                         newTemplate.Position = UDim2.new(1,-side.Width,0, v.GuiElems.Main.Position.Y.Offset + v.GuiElems.Main.Size.Y.Offset)
  5942.                     end)
  5943.                     sideResizerHook(newTemplate,"V",side,i)
  5944.                     newTemplate.Parent = side.Frame
  5945.                 end
  5946.             end
  5947.  
  5948.             --side.Frame.Back.Position = UDim2.new(0,0,0,0)
  5949.             --side.Frame.Back.Size = UDim2.new(0,side.Width,1,0)
  5950.         end
  5951.  
  5952.         local function updateSide(side,noTween)
  5953.             local oldHeight = 0
  5954.             local currentPos = 0
  5955.             local neededSize = 0
  5956.             local windows = side.Windows
  5957.             local height = sidesGui.AbsoluteSize.Y - (math.max(0,#windows - 1) * 4)
  5958.  
  5959.             for i,v in pairs(windows) do oldHeight = oldHeight + v.SizeY end
  5960.             for i,v in pairs(windows) do
  5961.                 if i == #windows then
  5962.                     v.SizeY = height-currentPos
  5963.                     neededSize = math.max(0,(v.MinY or 100)-v.SizeY)
  5964.                 else
  5965.                     v.SizeY = math.max(math.floor(v.SizeY/oldHeight*height),v.MinY or 100)
  5966.                 end
  5967.                 currentPos = currentPos + v.SizeY
  5968.             end
  5969.  
  5970.             if neededSize > 0 then
  5971.                 for i = #windows-1,1,-1 do
  5972.                     local window = windows[i]
  5973.                     local newSize = math.max(window.SizeY-neededSize,(window.MinY or 100))
  5974.                     neededSize = neededSize - (window.SizeY - newSize)
  5975.                     window.SizeY = newSize
  5976.                 end
  5977.                 local lastWindow = windows[#windows]
  5978.                 lastWindow.SizeY = (lastWindow.MinY or 100)-neededSize
  5979.             end
  5980.             renderSide(side,noTween)
  5981.         end
  5982.  
  5983.         updateWindows = function(noTween)
  5984.             updateSideFrames(noTween)
  5985.             updateSide(leftSide,noTween)
  5986.             updateSide(rightSide,noTween)
  5987.             local count = 0
  5988.             for i = #visibleWindows,1,-1 do
  5989.                 visibleWindows[i].Gui.DisplayOrder = displayOrderStart + count
  5990.                 Lib.ShowGui(visibleWindows[i].Gui)
  5991.                 count = count + 1
  5992.             end
  5993.  
  5994.             --[[local leftTweenPos = (#leftSide.Windows == 0 and UDim2.new(0,-leftSide.Width-5,0,0) or UDim2.new(0,0,0,0))
  5995.             leftSide.Frame:TweenPosition(leftTweenPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)
  5996.             local rightTweenPos = (#rightSide.Windows == 0 and UDim2.new(1,5,0,0) or UDim2.new(1,-rightSide.Width,0,0))
  5997.             rightSide.Frame:TweenPosition(rightTweenPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.3,true)]]
  5998.         end
  5999.  
  6000.         funcs.SetMinimized = function(self,set,mode)
  6001.             local oldVal = self.Minimized
  6002.             local newVal
  6003.             if set == nil then newVal = not self.Minimized else newVal = set end
  6004.             self.Minimized = newVal
  6005.             if not mode then mode = 1 end
  6006.  
  6007.             local resizeControls = self.GuiElems.ResizeControls
  6008.             local minimizeControls = {"North","NorthEast","NorthWest","South","SouthEast","SouthWest"}
  6009.             for i = 1,#minimizeControls do
  6010.                 local control = resizeControls:FindFirstChild(minimizeControls[i])
  6011.                 if control then control.Visible = not newVal end
  6012.             end
  6013.  
  6014.             if mode == 1 or mode == 2 then
  6015.                 self:StopTweens()
  6016.                 if mode == 1 then
  6017.                     self.GuiElems.Main:TweenSize(UDim2.new(0,self.SizeX,0,newVal and 20 or self.SizeY),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,0.25,true)
  6018.                 else
  6019.                     local maxY = sidesGui.AbsoluteSize.Y
  6020.                     local newPos = UDim2.new(0,self.PosX,0,newVal and math.min(maxY-20,self.PosY + self.SizeY - 20) or math.max(0,self.PosY - self.SizeY + 20))
  6021.  
  6022.                     self.GuiElems.Main:TweenPosition(newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quart,0.25,true)
  6023.                     self.GuiElems.Main:TweenSize(UDim2.new(0,self.SizeX,0,newVal and 20 or self.SizeY),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,0.25,true)
  6024.                 end
  6025.                 self.GuiElems.Minimize.ImageLabel.Image = newVal and "rbxassetid://5060023708" or "rbxassetid://5034768003"
  6026.             end
  6027.  
  6028.             if oldVal ~= newVal then
  6029.                 if newVal then
  6030.                     self.OnMinimize:Fire()
  6031.                 else
  6032.                     self.OnRestore:Fire()
  6033.                 end
  6034.             end
  6035.         end
  6036.  
  6037.         funcs.Resize = function(self,sizeX,sizeY)
  6038.             self.SizeX = sizeX or self.SizeX
  6039.             self.SizeY = sizeY or self.SizeY
  6040.             self.GuiElems.Main.Size = UDim2.new(0,self.SizeX,0,self.SizeY)
  6041.         end
  6042.  
  6043.         funcs.SetSize = funcs.Resize
  6044.  
  6045.         funcs.SetTitle = function(self,title)
  6046.             self.GuiElems.Title.Text = title
  6047.         end
  6048.  
  6049.         funcs.SetResizable = function(self,val)
  6050.             self.Resizable = val
  6051.             self.GuiElems.ResizeControls.Visible = self.Resizable and self.ResizableInternal
  6052.         end
  6053.  
  6054.         funcs.SetResizableInternal = function(self,val)
  6055.             self.ResizableInternal = val
  6056.             self.GuiElems.ResizeControls.Visible = self.Resizable and self.ResizableInternal
  6057.         end
  6058.  
  6059.         funcs.SetAligned = function(self,val)
  6060.             self.Aligned = val
  6061.             self:SetResizableInternal(not val)
  6062.             self.GuiElems.Main.Active = not val
  6063.             self.GuiElems.Main.Outlines.Visible = not val
  6064.             if not val then
  6065.                 for i,v in pairs(leftSide.Windows) do if v == self then table.remove(leftSide.Windows,i) break end end
  6066.                 for i,v in pairs(rightSide.Windows) do if v == self then table.remove(rightSide.Windows,i) break end end
  6067.                 if not table.find(visibleWindows,self) then table.insert(visibleWindows,1,self) end
  6068.                 self.GuiElems.Minimize.ImageLabel.Image = "rbxassetid://5034768003"
  6069.                 self.Side = nil
  6070.                 updateWindows()
  6071.             else
  6072.                 self:SetMinimized(false,3)
  6073.                 for i,v in pairs(visibleWindows) do if v == self then table.remove(visibleWindows,i) break end end
  6074.                 self.GuiElems.Minimize.ImageLabel.Image = "rbxassetid://5448127505"
  6075.             end
  6076.         end
  6077.  
  6078.         funcs.Add = function(self,obj,name)
  6079.             if type(obj) == "table" and obj.Gui and obj.Gui:IsA("GuiObject") then
  6080.                 obj.Gui.Parent = self.ContentPane
  6081.             else
  6082.                 obj.Parent = self.ContentPane
  6083.             end
  6084.             if name then self.Elements[name] = obj end
  6085.         end
  6086.  
  6087.         funcs.GetElement = function(self,obj,name)
  6088.             return self.Elements[name]
  6089.         end
  6090.  
  6091.         funcs.AlignTo = function(self,side,pos,size,silent)
  6092.             if table.find(side.Windows,self) or self.Closed then return end
  6093.  
  6094.             size = size or self.SizeY
  6095.             if size > 0 and size <= 1 then
  6096.                 local totalSideHeight = 0
  6097.                 for i,v in pairs(side.Windows) do totalSideHeight = totalSideHeight + v.SizeY end
  6098.                 self.SizeY = (totalSideHeight > 0 and totalSideHeight * size * 2) or size
  6099.             else
  6100.                 self.SizeY = (size > 0 and size or 100)
  6101.             end
  6102.  
  6103.             self:SetAligned(true)
  6104.             self.Side = side
  6105.             self.SizeX = side.Width
  6106.             self.Gui.DisplayOrder = sideDisplayOrder + 1
  6107.             for i,v in pairs(side.Windows) do v.Gui.DisplayOrder = sideDisplayOrder end
  6108.             pos = math.min(#side.Windows+1, pos or 1)
  6109.             self.SidePos = pos
  6110.             table.insert(side.Windows, pos, self)
  6111.  
  6112.             if not silent then
  6113.                 side.Hidden = false
  6114.             end
  6115.             -- updateWindows(silent)
  6116.         end
  6117.  
  6118.         funcs.Close = function(self)
  6119.             self.Closed = true
  6120.             self:SetResizableInternal(false)
  6121.  
  6122.             Lib.FindAndRemove(leftSide.Windows,self)
  6123.             Lib.FindAndRemove(rightSide.Windows,self)
  6124.             Lib.FindAndRemove(visibleWindows,self)
  6125.  
  6126.             self.MinimizeAnim.Disable()
  6127.             self.CloseAnim.Disable()
  6128.             self.ClosedSide = self.Side
  6129.             self.Side = nil
  6130.             self.OnDeactivate:Fire()
  6131.  
  6132.             if not self.Aligned then
  6133.                 self:StopTweens()
  6134.                 local ti = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  6135.  
  6136.                 local closeTime = tick()
  6137.                 self.LastClose = closeTime
  6138.  
  6139.                 self:DoTween(self.GuiElems.Main,ti,{Size = UDim2.new(0,self.SizeX,0,20)})
  6140.                 self:DoTween(self.GuiElems.Title,ti,{TextTransparency = 1})
  6141.                 self:DoTween(self.GuiElems.Minimize.ImageLabel,ti,{ImageTransparency = 1})
  6142.                 self:DoTween(self.GuiElems.Close.ImageLabel,ti,{ImageTransparency = 1})
  6143.                 Lib.FastWait(0.2)
  6144.                 if closeTime ~= self.LastClose then return end
  6145.  
  6146.                 self:DoTween(self.GuiElems.TopBar,ti,{BackgroundTransparency = 1})
  6147.                 self:DoTween(self.GuiElems.Outlines,ti,{ImageTransparency = 1})
  6148.                 Lib.FastWait(0.2)
  6149.                 if closeTime ~= self.LastClose then return end
  6150.             end
  6151.  
  6152.             self.Aligned = false
  6153.             self.Gui.Parent = nil
  6154.             updateWindows(true)
  6155.         end
  6156.  
  6157.         funcs.Hide = funcs.Close
  6158.  
  6159.         funcs.IsVisible = function(self)
  6160.             return not self.Closed and ((self.Side and not self.Side.Hidden) or not self.Side)
  6161.         end
  6162.  
  6163.         funcs.IsContentVisible = function(self)
  6164.             return self:IsVisible() and not self.Minimized
  6165.         end
  6166.  
  6167.         funcs.Focus = function(self)
  6168.             moveToTop(self)
  6169.         end
  6170.  
  6171.         funcs.MoveInBoundary = function(self)
  6172.             local posX,posY = self.PosX,self.PosY
  6173.             local maxX,maxY = sidesGui.AbsoluteSize.X,sidesGui.AbsoluteSize.Y
  6174.             posX = math.min(posX,maxX-self.SizeX)
  6175.             posY = math.min(posY,maxY-20)
  6176.             self.GuiElems.Main.Position = UDim2.new(0,posX,0,posY)
  6177.         end
  6178.  
  6179.         funcs.DoTween = function(self,...)
  6180.             local tween = service.TweenService:Create(...)
  6181.             self.Tweens[#self.Tweens+1] = tween
  6182.             tween:Play()
  6183.         end
  6184.  
  6185.         funcs.StopTweens = function(self)
  6186.             for i,v in pairs(self.Tweens) do
  6187.                 v:Cancel()
  6188.             end
  6189.             self.Tweens = {}
  6190.         end
  6191.  
  6192.         funcs.Show = function(self,data)
  6193.             return static.ShowWindow(self,data)
  6194.         end
  6195.  
  6196.         funcs.ShowAndFocus = function(self,data)
  6197.             static.ShowWindow(self,data)
  6198.             service.RunService.RenderStepped:wait()
  6199.             self:Focus()
  6200.         end
  6201.  
  6202.         static.ShowWindow = function(window,data)
  6203.             data = data or {}
  6204.             local align = data.Align
  6205.             local pos = data.Pos
  6206.             local size = data.Size
  6207.             local targetSide = (align == "left" and leftSide) or (align == "right" and rightSide)
  6208.  
  6209.             if not window.Closed then
  6210.                 if not window.Aligned then
  6211.                     window:SetMinimized(false)
  6212.                 elseif window.Side and not data.Silent then
  6213.                     static.SetSideVisible(window.Side,true)
  6214.                 end
  6215.                 return
  6216.             end
  6217.  
  6218.             window.Closed = false
  6219.             window.LastClose = tick()
  6220.             window.GuiElems.Title.TextTransparency = 0
  6221.             window.GuiElems.Minimize.ImageLabel.ImageTransparency = 0
  6222.             window.GuiElems.Close.ImageLabel.ImageTransparency = 0
  6223.             window.GuiElems.TopBar.BackgroundTransparency = 0
  6224.             window.GuiElems.Outlines.ImageTransparency = 0
  6225.             window.GuiElems.Minimize.ImageLabel.Image = "rbxassetid://5034768003"
  6226.             window.GuiElems.Main.Active = true
  6227.             window.GuiElems.Main.Outlines.Visible = true
  6228.             window:SetMinimized(false,3)
  6229.             window:SetResizableInternal(true)
  6230.             window.MinimizeAnim.Enable()
  6231.             window.CloseAnim.Enable()
  6232.  
  6233.             if align then
  6234.                 window:AlignTo(targetSide,pos,size,data.Silent)
  6235.             else
  6236.                 if align == nil and window.ClosedSide then -- Regular open
  6237.                     window:AlignTo(window.ClosedSide,window.SidePos,size,true)
  6238.                     static.SetSideVisible(window.ClosedSide,true)
  6239.                 else
  6240.                     if table.find(visibleWindows,window) then return end
  6241.  
  6242.                     -- TODO: make better
  6243.                     window.GuiElems.Main.Size = UDim2.new(0,window.SizeX,0,20)
  6244.                     local ti = TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  6245.                     window:StopTweens()
  6246.                     window:DoTween(window.GuiElems.Main,ti,{Size = UDim2.new(0,window.SizeX,0,window.SizeY)})
  6247.  
  6248.                     window.SizeY = size or window.SizeY
  6249.                     table.insert(visibleWindows,1,window)
  6250.                     updateWindows()
  6251.                 end
  6252.             end
  6253.  
  6254.             window.ClosedSide = nil
  6255.             window.OnActivate:Fire()
  6256.         end
  6257.  
  6258.         static.ToggleSide = function(name)
  6259.             local side = (name == "left" and leftSide or rightSide)
  6260.             side.Hidden = not side.Hidden
  6261.             for i,v in pairs(side.Windows) do
  6262.                 if side.Hidden then
  6263.                     v.OnDeactivate:Fire()
  6264.                 else
  6265.                     v.OnActivate:Fire()
  6266.                 end
  6267.             end
  6268.             updateWindows()
  6269.         end
  6270.  
  6271.         static.SetSideVisible = function(s,vis)
  6272.             local side = (type(s) == "table" and s) or (s == "left" and leftSide or rightSide)
  6273.             side.Hidden = not vis
  6274.             for i,v in pairs(side.Windows) do
  6275.                 if side.Hidden then
  6276.                     v.OnDeactivate:Fire()
  6277.                 else
  6278.                     v.OnActivate:Fire()
  6279.                 end
  6280.             end
  6281.             updateWindows()
  6282.         end
  6283.  
  6284.         static.Init = function()
  6285.             displayOrderStart = Main.DisplayOrders.Window
  6286.             sideDisplayOrder = Main.DisplayOrders.SideWindow
  6287.  
  6288.             sidesGui = Instance.new("ScreenGui")
  6289.             local leftFrame = create({
  6290.                 {1,"Frame",{Active=true,Name="LeftSide",BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,}},
  6291.                 {2,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2549019753933,0.2549019753933,0.2549019753933),BorderSizePixel=0,Font=3,Name="Resizer",Parent={1},Size=UDim2.new(0,5,1,0),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  6292.                 {3,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="Line",Parent={2},Position=UDim2.new(0,0,0,0),Size=UDim2.new(0,1,1,0),}},
  6293.                 {4,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2549019753933,0.2549019753933,0.2549019753933),BorderSizePixel=0,Font=3,Name="WindowResizer",Parent={1},Position=UDim2.new(1,-300,0,0),Size=UDim2.new(1,0,0,4),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  6294.                 {5,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="Line",Parent={4},Size=UDim2.new(1,0,0,1),}},
  6295.             })
  6296.             leftSide.Frame = leftFrame
  6297.             leftFrame.Position = UDim2.new(0,-leftSide.Width-10,0,0)
  6298.             leftSide.WindowResizer = leftFrame.WindowResizer
  6299.             leftFrame.WindowResizer.Parent = nil
  6300.             leftFrame.Parent = sidesGui
  6301.  
  6302.             local rightFrame = create({
  6303.                 {1,"Frame",{Active=true,Name="RightSide",BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,}},
  6304.                 {2,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2549019753933,0.2549019753933,0.2549019753933),BorderSizePixel=0,Font=3,Name="Resizer",Parent={1},Size=UDim2.new(0,5,1,0),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  6305.                 {3,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="Line",Parent={2},Position=UDim2.new(0,4,0,0),Size=UDim2.new(0,1,1,0),}},
  6306.                 {4,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2549019753933,0.2549019753933,0.2549019753933),BorderSizePixel=0,Font=3,Name="WindowResizer",Parent={1},Position=UDim2.new(1,-300,0,0),Size=UDim2.new(1,0,0,4),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  6307.                 {5,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="Line",Parent={4},Size=UDim2.new(1,0,0,1),}},
  6308.             })
  6309.             rightSide.Frame = rightFrame
  6310.             rightFrame.Position = UDim2.new(1,10,0,0)
  6311.             rightSide.WindowResizer = rightFrame.WindowResizer
  6312.             rightFrame.WindowResizer.Parent = nil
  6313.             rightFrame.Parent = sidesGui
  6314.  
  6315.             sideResizerHook(leftFrame.Resizer,"H",leftSide)
  6316.             sideResizerHook(rightFrame.Resizer,"H",rightSide)
  6317.  
  6318.             alignIndicator = Instance.new("ScreenGui")
  6319.             alignIndicator.DisplayOrder = Main.DisplayOrders.Core
  6320.             local indicator = Instance.new("Frame",alignIndicator)
  6321.             indicator.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
  6322.             indicator.BorderSizePixel = 0
  6323.             indicator.BackgroundTransparency = 0.8
  6324.             indicator.Name = "Indicator"
  6325.             local corner = Instance.new("UICorner",indicator)
  6326.             corner.CornerRadius = UDim.new(0,10)
  6327.  
  6328.             local leftToggle = create({{1,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderMode=2,Font=10,Name="LeftToggle",Position=UDim2.new(0,0,0,-36),Size=UDim2.new(0,16,0,36),Text="<",TextColor3=Color3.new(1,1,1),TextSize=14,}}})
  6329.             local rightToggle = leftToggle:Clone()
  6330.             rightToggle.Name = "RightToggle"
  6331.             rightToggle.Position = UDim2.new(1,-16,0,-36)
  6332.             Lib.ButtonAnim(leftToggle,{Mode = 2,PressColor = Color3.fromRGB(32,32,32)})
  6333.             Lib.ButtonAnim(rightToggle,{Mode = 2,PressColor = Color3.fromRGB(32,32,32)})
  6334.  
  6335.             leftToggle.MouseButton1Click:Connect(function()
  6336.                 static.ToggleSide("left")
  6337.             end)
  6338.  
  6339.             rightToggle.MouseButton1Click:Connect(function()
  6340.                 static.ToggleSide("right")
  6341.             end)
  6342.  
  6343.             leftToggle.Parent = sidesGui
  6344.             rightToggle.Parent = sidesGui
  6345.  
  6346.             sidesGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
  6347.                 local maxWidth = math.max(300,sidesGui.AbsoluteSize.X-static.FreeWidth)
  6348.                 leftSide.Width = math.max(static.MinWidth,math.min(leftSide.Width,maxWidth-rightSide.Width))
  6349.                 rightSide.Width = math.max(static.MinWidth,math.min(rightSide.Width,maxWidth-leftSide.Width))
  6350.                 for i = 1,#visibleWindows do
  6351.                     visibleWindows[i]:MoveInBoundary()
  6352.                 end
  6353.                 updateWindows(true)
  6354.             end)
  6355.  
  6356.             sidesGui.DisplayOrder = sideDisplayOrder - 1
  6357.             Lib.ShowGui(sidesGui)
  6358.             updateSideFrames()
  6359.         end
  6360.  
  6361.         local mt = {__index = funcs}
  6362.         static.new = function()
  6363.             local obj = setmetatable({
  6364.                 Minimized = false,
  6365.                 Dragging = false,
  6366.                 Resizing = false,
  6367.                 Aligned = false,
  6368.                 Draggable = true,
  6369.                 Resizable = true,
  6370.                 ResizableInternal = true,
  6371.                 Alignable = true,
  6372.                 Closed = true,
  6373.                 SizeX = 300,
  6374.                 SizeY = 300,
  6375.                 MinX = 200,
  6376.                 MinY = 200,
  6377.                 PosX = 0,
  6378.                 PosY = 0,
  6379.                 GuiElems = {},
  6380.                 Tweens = {},
  6381.                 Elements = {},
  6382.                 OnActivate = Lib.Signal.new(),
  6383.                 OnDeactivate = Lib.Signal.new(),
  6384.                 OnMinimize = Lib.Signal.new(),
  6385.                 OnRestore = Lib.Signal.new()
  6386.             },mt)
  6387.             obj.Gui = createGui(obj)
  6388.             return obj
  6389.         end
  6390.  
  6391.         return static
  6392.     end)()
  6393.  
  6394.     Lib.ContextMenu = (function()
  6395.         local funcs = {}
  6396.         local mouse
  6397.  
  6398.         local function createGui(self)
  6399.             local contextGui = create({
  6400.                 {1,"ScreenGui",{DisplayOrder=1000000,Name="Context",ZIndexBehavior=1,}},
  6401.                 {2,"Frame",{Active=true,BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),Name="Main",Parent={1},Position=UDim2.new(0.5,-100,0.5,-150),Size=UDim2.new(0,200,0,100),}},
  6402.                 {3,"UICorner",{CornerRadius=UDim.new(0,4),Parent={2},}},
  6403.                 {4,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),Name="Container",Parent={2},Position=UDim2.new(0,1,0,1),Size=UDim2.new(1,-2,1,-2),}},
  6404.                 {5,"UICorner",{CornerRadius=UDim.new(0,4),Parent={4},}},
  6405.                 {6,"ScrollingFrame",{Active=true,BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BackgroundTransparency=1,BorderSizePixel=0,CanvasSize=UDim2.new(0,0,0,0),Name="List",Parent={4},Position=UDim2.new(0,2,0,2),ScrollBarImageColor3=Color3.new(0,0,0),ScrollBarThickness=4,Size=UDim2.new(1,-4,1,-4),VerticalScrollBarInset=1,}},
  6406.                 {7,"UIListLayout",{Parent={6},SortOrder=2,}},
  6407.                 {8,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="SearchFrame",Parent={4},Size=UDim2.new(1,0,0,24),Visible=false,}},
  6408.                 {9,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.1176470592618,0.1176470592618,0.1176470592618),BorderSizePixel=0,Name="SearchContainer",Parent={8},Position=UDim2.new(0,3,0,3),Size=UDim2.new(1,-6,0,18),}},
  6409.                 {10,"TextBox",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="SearchBox",Parent={9},PlaceholderColor3=Color3.new(0.39215689897537,0.39215689897537,0.39215689897537),PlaceholderText="Search",Position=UDim2.new(0,4,0,0),Size=UDim2.new(1,-8,0,18),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=0,}},
  6410.                 {11,"UICorner",{CornerRadius=UDim.new(0,2),Parent={9},}},
  6411.                 {12,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="Line",Parent={8},Position=UDim2.new(0,0,1,0),Size=UDim2.new(1,0,0,1),}},
  6412.                 {13,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BackgroundTransparency=1,BorderColor3=Color3.new(0.33725491166115,0.49019610881805,0.73725491762161),BorderSizePixel=0,Font=3,Name="Entry",Parent={1},Size=UDim2.new(1,0,0,22),Text="",TextSize=14,Visible=false,}},
  6413.                 {14,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="EntryName",Parent={13},Position=UDim2.new(0,24,0,0),Size=UDim2.new(1,-24,1,0),Text="Duplicate",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  6414.                 {15,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Shortcut",Parent={13},Position=UDim2.new(0,24,0,0),Size=UDim2.new(1,-30,1,0),Text="Ctrl+D",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  6415.                 {16,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,ImageRectOffset=Vector2.new(304,0),ImageRectSize=Vector2.new(16,16),Name="Icon",Parent={13},Position=UDim2.new(0,2,0,3),ScaleType=4,Size=UDim2.new(0,16,0,16),}},
  6416.                 {17,"UICorner",{CornerRadius=UDim.new(0,4),Parent={13},}},
  6417.                 {18,"Frame",{BackgroundColor3=Color3.new(0.21568629145622,0.21568629145622,0.21568629145622),BackgroundTransparency=1,BorderSizePixel=0,Name="Divider",Parent={1},Position=UDim2.new(0,0,0,20),Size=UDim2.new(1,0,0,7),Visible=false,}},
  6418.                 {19,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="Line",Parent={18},Position=UDim2.new(0,0,0.5,0),Size=UDim2.new(1,0,0,1),}},
  6419.                 {20,"TextLabel",{AnchorPoint=Vector2.new(0,0.5),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="DividerName",Parent={18},Position=UDim2.new(0,2,0.5,0),Size=UDim2.new(1,-4,1,0),Text="Objects",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.60000002384186,TextXAlignment=0,Visible=false,}},
  6420.             })
  6421.             self.GuiElems.Main = contextGui.Main
  6422.             self.GuiElems.List = contextGui.Main.Container.List
  6423.             self.GuiElems.Entry = contextGui.Entry
  6424.             self.GuiElems.Divider = contextGui.Divider
  6425.             self.GuiElems.SearchFrame = contextGui.Main.Container.SearchFrame
  6426.             self.GuiElems.SearchBar = self.GuiElems.SearchFrame.SearchContainer.SearchBox
  6427.             Lib.ViewportTextBox.convert(self.GuiElems.SearchBar)
  6428.  
  6429.             self.GuiElems.SearchBar:GetPropertyChangedSignal("Text"):Connect(function()
  6430.                 local lower,find = string.lower,string.find
  6431.                 local searchText = lower(self.GuiElems.SearchBar.Text)
  6432.                 local items = self.Items
  6433.                 local map = self.ItemToEntryMap
  6434.  
  6435.                 if searchText ~= "" then
  6436.                     local results = {}
  6437.                     local count = 1
  6438.                     for i = 1,#items do
  6439.                         local item = items[i]
  6440.                         local entry = map[item]
  6441.                         if entry then
  6442.                             if not item.Divider and find(lower(item.Name),searchText,1,true) then
  6443.                                 results[count] = item
  6444.                                 count = count + 1
  6445.                             else
  6446.                                 entry.Visible = false
  6447.                             end
  6448.                         end
  6449.                     end
  6450.                     table.sort(results,function(a,b) return a.Name < b.Name end)
  6451.                     for i = 1,#results do
  6452.                         local entry = map[results[i]]
  6453.                         entry.LayoutOrder = i
  6454.                         entry.Visible = true
  6455.                     end
  6456.                 else
  6457.                     for i = 1,#items do
  6458.                         local entry = map[items[i]]
  6459.                         if entry then entry.LayoutOrder = i entry.Visible = true end
  6460.                     end
  6461.                 end
  6462.  
  6463.                 local toSize = self.GuiElems.List.UIListLayout.AbsoluteContentSize.Y + 6
  6464.                 self.GuiElems.List.CanvasSize = UDim2.new(0,0,0,toSize-6)
  6465.             end)
  6466.  
  6467.             return contextGui
  6468.         end
  6469.  
  6470.         funcs.Add = function(self,item)
  6471.             local newItem = {
  6472.                 Name = item.Name or "Item",
  6473.                 Icon = item.Icon or "",
  6474.                 Shortcut = item.Shortcut or "",
  6475.                 OnClick = item.OnClick,
  6476.                 OnHover = item.OnHover,
  6477.                 Disabled = item.Disabled or false,
  6478.                 DisabledIcon = item.DisabledIcon or "",
  6479.                 IconMap = item.IconMap,
  6480.                 OnRightClick = item.OnRightClick
  6481.             }
  6482.             if self.QueuedDivider then
  6483.                 local text = self.QueuedDividerText and #self.QueuedDividerText > 0 and self.QueuedDividerText
  6484.                 self:AddDivider(text)
  6485.             end
  6486.             self.Items[#self.Items+1] = newItem
  6487.             self.Updated = nil
  6488.         end
  6489.  
  6490.         funcs.AddRegistered = function(self,name,disabled)
  6491.             if not self.Registered[name] then error(name.." is not registered") end
  6492.            
  6493.             if self.QueuedDivider then
  6494.                 local text = self.QueuedDividerText and #self.QueuedDividerText > 0 and self.QueuedDividerText
  6495.                 self:AddDivider(text)
  6496.             end
  6497.             self.Registered[name].Disabled = disabled
  6498.             self.Items[#self.Items+1] = self.Registered[name]
  6499.             self.Updated = nil
  6500.         end
  6501.  
  6502.         funcs.Register = function(self,name,item)
  6503.             self.Registered[name] = {
  6504.                 Name = item.Name or "Item",
  6505.                 Icon = item.Icon or "",
  6506.                 Shortcut = item.Shortcut or "",
  6507.                 OnClick = item.OnClick,
  6508.                 OnHover = item.OnHover,
  6509.                 DisabledIcon = item.DisabledIcon or "",
  6510.                 IconMap = item.IconMap,
  6511.                 OnRightClick = item.OnRightClick
  6512.             }
  6513.         end
  6514.  
  6515.         funcs.UnRegister = function(self,name)
  6516.             self.Registered[name] = nil
  6517.         end
  6518.  
  6519.         funcs.AddDivider = function(self,text)
  6520.             self.QueuedDivider = false
  6521.             local textWidth = text and service.TextService:GetTextSize(text,14,Enum.Font.SourceSans,Vector2.new(999999999,20)).X or nil
  6522.             table.insert(self.Items,{Divider = true, Text = text, TextSize = textWidth and textWidth+4})
  6523.             self.Updated = nil
  6524.         end
  6525.        
  6526.         funcs.QueueDivider = function(self,text)
  6527.             self.QueuedDivider = true
  6528.             self.QueuedDividerText = text or ""
  6529.         end
  6530.  
  6531.         funcs.Clear = function(self)
  6532.             self.Items = {}
  6533.             self.Updated = nil
  6534.         end
  6535.  
  6536.         funcs.Refresh = function(self)
  6537.             for i,v in pairs(self.GuiElems.List:GetChildren()) do
  6538.                 if not v:IsA("UIListLayout") then
  6539.                     v:Destroy()
  6540.                 end
  6541.             end
  6542.             local map = {}
  6543.             self.ItemToEntryMap = map
  6544.  
  6545.             local dividerFrame = self.GuiElems.Divider
  6546.             local contextList = self.GuiElems.List
  6547.             local entryFrame = self.GuiElems.Entry
  6548.             local items = self.Items
  6549.  
  6550.             for i = 1,#items do
  6551.                 local item = items[i]
  6552.                 if item.Divider then
  6553.                     local newDivider = dividerFrame:Clone()
  6554.                     newDivider.Line.BackgroundColor3 = self.Theme.DividerColor
  6555.                     if item.Text then
  6556.                         newDivider.Size = UDim2.new(1,0,0,20)
  6557.                         newDivider.Line.Position = UDim2.new(0,item.TextSize,0.5,0)
  6558.                         newDivider.Line.Size = UDim2.new(1,-item.TextSize,0,1)
  6559.                         newDivider.DividerName.TextColor3 = self.Theme.TextColor
  6560.                         newDivider.DividerName.Text = item.Text
  6561.                         newDivider.DividerName.Visible = true
  6562.                     end
  6563.                     newDivider.Visible = true
  6564.                     map[item] = newDivider
  6565.                     newDivider.Parent = contextList
  6566.                 else
  6567.                     local newEntry = entryFrame:Clone()
  6568.                     newEntry.BackgroundColor3 = self.Theme.HighlightColor
  6569.                     newEntry.EntryName.TextColor3 = self.Theme.TextColor
  6570.                     newEntry.EntryName.Text = item.Name
  6571.                     newEntry.Shortcut.Text = item.Shortcut
  6572.                     if item.Disabled then
  6573.                         newEntry.EntryName.TextColor3 = Color3.new(150/255,150/255,150/255)
  6574.                         newEntry.Shortcut.TextColor3 = Color3.new(150/255,150/255,150/255)
  6575.                     end
  6576.  
  6577.                     if self.Iconless then
  6578.                         newEntry.EntryName.Position = UDim2.new(0,2,0,0)
  6579.                         newEntry.EntryName.Size = UDim2.new(1,-4,0,20)
  6580.                         newEntry.Icon.Visible = false
  6581.                     else
  6582.                         local iconIndex = item.Disabled and item.DisabledIcon or item.Icon
  6583.                         if item.IconMap then
  6584.                             if type(iconIndex) == "number" then
  6585.                                 item.IconMap:Display(newEntry.Icon,iconIndex)
  6586.                             elseif type(iconIndex) == "string" then
  6587.                                 item.IconMap:DisplayByKey(newEntry.Icon,iconIndex)
  6588.                             end
  6589.                         elseif type(iconIndex) == "string" then
  6590.                             newEntry.Icon.Image = iconIndex
  6591.                         end
  6592.                     end
  6593.  
  6594.                     if not item.Disabled then
  6595.                         if item.OnClick then
  6596.                             newEntry.MouseButton1Click:Connect(function()
  6597.                                 item.OnClick(item.Name)
  6598.                                 if not item.NoHide then
  6599.                                     self:Hide()
  6600.                                 end
  6601.                             end)
  6602.                         end
  6603.  
  6604.                         if item.OnRightClick then
  6605.                             newEntry.MouseButton2Click:Connect(function()
  6606.                                 item.OnRightClick(item.Name)
  6607.                                 if not item.NoHide then
  6608.                                     self:Hide()
  6609.                                 end
  6610.                             end)
  6611.                         end
  6612.                     end
  6613.  
  6614.                     newEntry.InputBegan:Connect(function(input)
  6615.                         if input.UserInputType == Enum.UserInputType.MouseMovement then
  6616.                             newEntry.BackgroundTransparency = 0
  6617.                         end
  6618.                     end)
  6619.  
  6620.                     newEntry.InputEnded:Connect(function(input)
  6621.                         if input.UserInputType == Enum.UserInputType.MouseMovement then
  6622.                             newEntry.BackgroundTransparency = 1
  6623.                         end
  6624.                     end)
  6625.  
  6626.                     newEntry.Visible = true
  6627.                     map[item] = newEntry
  6628.                     newEntry.Parent = contextList
  6629.                 end
  6630.             end
  6631.             self.Updated = true
  6632.         end
  6633.  
  6634.         funcs.Show = function(self,x,y)
  6635.             -- Initialize Gui
  6636.             local elems = self.GuiElems
  6637.             elems.SearchFrame.Visible = self.SearchEnabled
  6638.             elems.List.Position = UDim2.new(0,2,0,2 + (self.SearchEnabled and 24 or 0))
  6639.             elems.List.Size = UDim2.new(1,-4,1,-4 - (self.SearchEnabled and 24 or 0))
  6640.             if self.SearchEnabled and self.ClearSearchOnShow then elems.SearchBar.Text = "" end
  6641.             self.GuiElems.List.CanvasPosition = Vector2.new(0,0)
  6642.  
  6643.             if not self.Updated then
  6644.                 self:Refresh() -- Create entries
  6645.             end
  6646.  
  6647.             -- Vars
  6648.             local reverseY = false
  6649.             local x,y = x or mouse.X, y or mouse.Y
  6650.             local maxX,maxY = mouse.ViewSizeX,mouse.ViewSizeY
  6651.  
  6652.             -- Position and show
  6653.             if x + self.Width > maxX then
  6654.                 x = self.ReverseX and x - self.Width or maxX - self.Width
  6655.             end
  6656.             elems.Main.Position = UDim2.new(0,x,0,y)
  6657.             elems.Main.Size = UDim2.new(0,self.Width,0,0)
  6658.             self.Gui.DisplayOrder = Main.DisplayOrders.Menu
  6659.             Lib.ShowGui(self.Gui)
  6660.  
  6661.             -- Size adjustment
  6662.             local toSize = elems.List.UIListLayout.AbsoluteContentSize.Y + 6 -- Padding
  6663.             if self.MaxHeight and toSize > self.MaxHeight then
  6664.                 elems.List.CanvasSize = UDim2.new(0,0,0,toSize-6)
  6665.                 toSize = self.MaxHeight
  6666.             else
  6667.                 elems.List.CanvasSize = UDim2.new(0,0,0,0)
  6668.             end
  6669.             if y + toSize > maxY then reverseY = true end
  6670.  
  6671.             -- Close event
  6672.             local closable
  6673.             if self.CloseEvent then self.CloseEvent:Disconnect() end
  6674.             self.CloseEvent = service.UserInputService.InputBegan:Connect(function(input)
  6675.                 if not closable or input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  6676.  
  6677.                 if not Lib.CheckMouseInGui(elems.Main) then
  6678.                     self.CloseEvent:Disconnect()
  6679.                     self:Hide()
  6680.                 end
  6681.             end)
  6682.  
  6683.             -- Resize
  6684.             if reverseY then
  6685.                 elems.Main.Position = UDim2.new(0,x,0,y-(self.ReverseYOffset or 0))
  6686.                 local newY = y - toSize - (self.ReverseYOffset or 0)
  6687.                 y = newY >= 0 and newY or 0
  6688.                 elems.Main:TweenSizeAndPosition(UDim2.new(0,self.Width,0,toSize),UDim2.new(0,x,0,y),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,0.2,true)
  6689.             else
  6690.                 elems.Main:TweenSize(UDim2.new(0,self.Width,0,toSize),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,0.2,true)
  6691.             end
  6692.  
  6693.             -- Close debounce
  6694.             Lib.FastWait()
  6695.             if self.SearchEnabled and self.FocusSearchOnShow then elems.SearchBar:CaptureFocus() end
  6696.             closable = true
  6697.         end
  6698.  
  6699.         funcs.Hide = function(self)
  6700.             self.Gui.Parent = nil
  6701.         end
  6702.  
  6703.         funcs.ApplyTheme = function(self,data)
  6704.             local theme = self.Theme
  6705.             theme.ContentColor = data.ContentColor or Settings.Theme.Menu
  6706.             theme.OutlineColor = data.OutlineColor or Settings.Theme.Menu
  6707.             theme.DividerColor = data.DividerColor or Settings.Theme.Outline2
  6708.             theme.TextColor = data.TextColor or Settings.Theme.Text
  6709.             theme.HighlightColor = data.HighlightColor or Settings.Theme.Main1
  6710.  
  6711.             self.GuiElems.Main.BackgroundColor3 = theme.OutlineColor
  6712.             self.GuiElems.Main.Container.BackgroundColor3 = theme.ContentColor
  6713.         end
  6714.  
  6715.         local mt = {__index = funcs}
  6716.         local function new()
  6717.             if not mouse then mouse = Main.Mouse or service.Players.LocalPlayer:GetMouse() end
  6718.  
  6719.             local obj = setmetatable({
  6720.                 Width = 200,
  6721.                 MaxHeight = nil,
  6722.                 Iconless = false,
  6723.                 SearchEnabled = false,
  6724.                 ClearSearchOnShow = true,
  6725.                 FocusSearchOnShow = true,
  6726.                 Updated = false,
  6727.                 QueuedDivider = false,
  6728.                 QueuedDividerText = "",
  6729.                 Items = {},
  6730.                 Registered = {},
  6731.                 GuiElems = {},
  6732.                 Theme = {}
  6733.             },mt)
  6734.             obj.Gui = createGui(obj)
  6735.             obj:ApplyTheme({})
  6736.             return obj
  6737.         end
  6738.  
  6739.         return {new = new}
  6740.     end)()
  6741.  
  6742.     Lib.CodeFrame = (function()
  6743.         local funcs = {}
  6744.  
  6745.         local typeMap = {
  6746.             [1] = "String",
  6747.             [2] = "String",
  6748.             [3] = "String",
  6749.             [4] = "Comment",
  6750.             [5] = "Operator",
  6751.             [6] = "Number",
  6752.             [7] = "Keyword",
  6753.             [8] = "BuiltIn",
  6754.             [9] = "LocalMethod",
  6755.             [10] = "LocalProperty",
  6756.             [11] = "Nil",
  6757.             [12] = "Bool",
  6758.             [13] = "Function",
  6759.             [14] = "Local",
  6760.             [15] = "Self",
  6761.             [16] = "FunctionName",
  6762.             [17] = "Bracket"
  6763.         }
  6764.  
  6765.         local specialKeywordsTypes = {
  6766.             ["nil"] = 11,
  6767.             ["true"] = 12,
  6768.             ["false"] = 12,
  6769.             ["function"] = 13,
  6770.             ["local"] = 14,
  6771.             ["self"] = 15
  6772.         }
  6773.  
  6774.         local keywords = {
  6775.             ["and"] = true,
  6776.             ["break"] = true,
  6777.             ["do"] = true,
  6778.             ["else"] = true,
  6779.             ["elseif"] = true,
  6780.             ["end"] = true,
  6781.             ["false"] = true,
  6782.             ["for"] = true,
  6783.             ["function"] = true,
  6784.             ["if"] = true,
  6785.             ["in"] = true,
  6786.             ["local"] = true,
  6787.             ["nil"] = true,
  6788.             ["not"] = true,
  6789.             ["or"] = true,
  6790.             ["repeat"] = true,
  6791.             ["return"] = true,
  6792.             ["then"] = true,
  6793.             ["true"] = true,
  6794.             ["until"] = true,
  6795.             ["while"] = true,
  6796.             ["plugin"] = true
  6797.         }
  6798.  
  6799.         local builtIns = {
  6800.             ["delay"] = true,
  6801.             ["elapsedTime"] = true,
  6802.             ["require"] = true,
  6803.             ["spawn"] = true,
  6804.             ["tick"] = true,
  6805.             ["time"] = true,
  6806.             ["typeof"] = true,
  6807.             ["UserSettings"] = true,
  6808.             ["wait"] = true,
  6809.             ["warn"] = true,
  6810.             ["game"] = true,
  6811.             ["shared"] = true,
  6812.             ["script"] = true,
  6813.             ["workspace"] = true,
  6814.             ["assert"] = true,
  6815.             ["collectgarbage"] = true,
  6816.             ["error"] = true,
  6817.             ["getfenv"] = true,
  6818.             ["getmetatable"] = true,
  6819.             ["ipairs"] = true,
  6820.             ["loadstring"] = true,
  6821.             ["newproxy"] = true,
  6822.             ["next"] = true,
  6823.             ["pairs"] = true,
  6824.             ["pcall"] = true,
  6825.             ["print"] = true,
  6826.             ["rawequal"] = true,
  6827.             ["rawget"] = true,
  6828.             ["rawset"] = true,
  6829.             ["select"] = true,
  6830.             ["setfenv"] = true,
  6831.             ["setmetatable"] = true,
  6832.             ["tonumber"] = true,
  6833.             ["tostring"] = true,
  6834.             ["type"] = true,
  6835.             ["unpack"] = true,
  6836.             ["xpcall"] = true,
  6837.             ["_G"] = true,
  6838.             ["_VERSION"] = true,
  6839.             ["coroutine"] = true,
  6840.             ["debug"] = true,
  6841.             ["math"] = true,
  6842.             ["os"] = true,
  6843.             ["string"] = true,
  6844.             ["table"] = true,
  6845.             ["bit32"] = true,
  6846.             ["utf8"] = true,
  6847.             ["Axes"] = true,
  6848.             ["BrickColor"] = true,
  6849.             ["CFrame"] = true,
  6850.             ["Color3"] = true,
  6851.             ["ColorSequence"] = true,
  6852.             ["ColorSequenceKeypoint"] = true,
  6853.             ["DockWidgetPluginGuiInfo"] = true,
  6854.             ["Enum"] = true,
  6855.             ["Faces"] = true,
  6856.             ["Instance"] = true,
  6857.             ["NumberRange"] = true,
  6858.             ["NumberSequence"] = true,
  6859.             ["NumberSequenceKeypoint"] = true,
  6860.             ["PathWaypoint"] = true,
  6861.             ["PhysicalProperties"] = true,
  6862.             ["Random"] = true,
  6863.             ["Ray"] = true,
  6864.             ["Rect"] = true,
  6865.             ["Region3"] = true,
  6866.             ["Region3int16"] = true,
  6867.             ["TweenInfo"] = true,
  6868.             ["UDim"] = true,
  6869.             ["UDim2"] = true,
  6870.             ["Vector2"] = true,
  6871.             ["Vector2int16"] = true,
  6872.             ["Vector3"] = true,
  6873.             ["Vector3int16"] = true
  6874.         }
  6875.  
  6876.         local builtInInited = false
  6877.  
  6878.         local richReplace = {
  6879.             ["'"] = "&apos;",
  6880.             ["\""] = "&quot;",
  6881.             ["<"] = "&lt;",
  6882.             [">"] = "&gt;",
  6883.             ["&"] = "&amp;"
  6884.         }
  6885.        
  6886.         local tabSub = "\205"
  6887.         local tabReplacement = (" %s%s "):format(tabSub,tabSub)
  6888.        
  6889.         local tabJumps = {
  6890.             [("[^%s] %s"):format(tabSub,tabSub)] = 0,
  6891.             [(" %s%s"):format(tabSub,tabSub)] = -1,
  6892.             [("%s%s "):format(tabSub,tabSub)] = 2,
  6893.             [("%s [^%s]"):format(tabSub,tabSub)] = 1,
  6894.         }
  6895.        
  6896.         local tweenService = service.TweenService
  6897.         local lineTweens = {}
  6898.  
  6899.         local function initBuiltIn()
  6900.             local env = getfenv()
  6901.             local type = type
  6902.             local tostring = tostring
  6903.             for name,_ in next,builtIns do
  6904.                 local envVal = env[name]
  6905.                 if type(envVal) == "table" then
  6906.                     local items = {}
  6907.                     for i,v in next,envVal do
  6908.                         items[i] = true
  6909.                     end
  6910.                     builtIns[name] = items
  6911.                 end
  6912.             end
  6913.  
  6914.             local enumEntries = {}
  6915.             local enums = Enum:GetEnums()
  6916.             for i = 1,#enums do
  6917.                 enumEntries[tostring(enums[i])] = true
  6918.             end
  6919.             builtIns["Enum"] = enumEntries
  6920.  
  6921.             builtInInited = true
  6922.         end
  6923.        
  6924.         local function setupEditBox(obj)
  6925.             local editBox = obj.GuiElems.EditBox
  6926.            
  6927.             editBox.Focused:Connect(function()
  6928.                 obj:ConnectEditBoxEvent()
  6929.                 obj.Editing = true
  6930.             end)
  6931.            
  6932.             editBox.FocusLost:Connect(function()
  6933.                 obj:DisconnectEditBoxEvent()
  6934.                 obj.Editing = false
  6935.             end)
  6936.            
  6937.             editBox:GetPropertyChangedSignal("Text"):Connect(function()
  6938.                 local text = editBox.Text
  6939.                 if #text == 0 or obj.EditBoxCopying then return end
  6940.                 editBox.Text = ""
  6941.                 obj:AppendText(text)
  6942.             end)
  6943.         end
  6944.        
  6945.         local function setupMouseSelection(obj)
  6946.             local mouse = plr:GetMouse()
  6947.             local codeFrame = obj.GuiElems.LinesFrame
  6948.             local lines = obj.Lines
  6949.            
  6950.             codeFrame.InputBegan:Connect(function(input)
  6951.                 if input.UserInputType == Enum.UserInputType.MouseButton1 then
  6952.                     local fontSizeX,fontSizeY = math.ceil(obj.FontSize/2),obj.FontSize
  6953.                    
  6954.                     local relX = mouse.X - codeFrame.AbsolutePosition.X
  6955.                     local relY = mouse.Y - codeFrame.AbsolutePosition.Y
  6956.                     local selX = math.round(relX / fontSizeX) + obj.ViewX
  6957.                     local selY = math.floor(relY / fontSizeY) + obj.ViewY
  6958.                     local releaseEvent,mouseEvent,scrollEvent
  6959.                     local scrollPowerV,scrollPowerH = 0,0
  6960.                     selY = math.min(#lines-1,selY)
  6961.                     local relativeLine = lines[selY+1] or ""
  6962.                     selX = math.min(#relativeLine, selX + obj:TabAdjust(selX,selY))
  6963.  
  6964.                     obj.SelectionRange = {{-1,-1},{-1,-1}}
  6965.                     obj:MoveCursor(selX,selY)
  6966.                     obj.FloatCursorX = selX
  6967.  
  6968.                     local function updateSelection()
  6969.                         local relX = mouse.X - codeFrame.AbsolutePosition.X
  6970.                         local relY = mouse.Y - codeFrame.AbsolutePosition.Y
  6971.                         local sel2X = math.max(0,math.round(relX / fontSizeX) + obj.ViewX)
  6972.                         local sel2Y = math.max(0,math.floor(relY / fontSizeY) + obj.ViewY)
  6973.  
  6974.                         sel2Y = math.min(#lines-1,sel2Y)
  6975.                         local relativeLine = lines[sel2Y+1] or ""
  6976.                         sel2X = math.min(#relativeLine, sel2X + obj:TabAdjust(sel2X,sel2Y))
  6977.  
  6978.                         if sel2Y < selY or (sel2Y == selY and sel2X < selX) then
  6979.                             obj.SelectionRange = {{sel2X,sel2Y},{selX,selY}}
  6980.                         else                       
  6981.                             obj.SelectionRange = {{selX,selY},{sel2X,sel2Y}}
  6982.                         end
  6983.  
  6984.                         obj:MoveCursor(sel2X,sel2Y)
  6985.                         obj.FloatCursorX = sel2X
  6986.                         obj:Refresh()
  6987.                     end
  6988.  
  6989.                     releaseEvent = service.UserInputService.InputEnded:Connect(function(input)
  6990.                         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  6991.                             releaseEvent:Disconnect()
  6992.                             mouseEvent:Disconnect()
  6993.                             scrollEvent:Disconnect()
  6994.                             obj:SetCopyableSelection()
  6995.                             --updateSelection()
  6996.                         end
  6997.                     end)
  6998.  
  6999.                     mouseEvent = service.UserInputService.InputChanged:Connect(function(input)
  7000.                         if input.UserInputType == Enum.UserInputType.MouseMovement then
  7001.                             local upDelta = mouse.Y - codeFrame.AbsolutePosition.Y
  7002.                             local downDelta = mouse.Y - codeFrame.AbsolutePosition.Y - codeFrame.AbsoluteSize.Y
  7003.                             local leftDelta = mouse.X - codeFrame.AbsolutePosition.X
  7004.                             local rightDelta = mouse.X - codeFrame.AbsolutePosition.X - codeFrame.AbsoluteSize.X
  7005.                             scrollPowerV = 0
  7006.                             scrollPowerH = 0
  7007.                             if downDelta > 0 then
  7008.                                 scrollPowerV = math.floor(downDelta*0.05) + 1
  7009.                             elseif upDelta < 0 then
  7010.                                 scrollPowerV = math.ceil(upDelta*0.05) - 1
  7011.                             end
  7012.                             if rightDelta > 0 then
  7013.                                 scrollPowerH = math.floor(rightDelta*0.05) + 1
  7014.                             elseif leftDelta < 0 then
  7015.                                 scrollPowerH = math.ceil(leftDelta*0.05) - 1
  7016.                             end
  7017.                             updateSelection()
  7018.                         end
  7019.                     end)
  7020.  
  7021.                     scrollEvent = cloneref(game["Run Service"].Parent:GetService("RunService")).RenderStepped:Connect(function()
  7022.                         if scrollPowerV ~= 0 or scrollPowerH ~= 0 then
  7023.                             obj:ScrollDelta(scrollPowerH,scrollPowerV)
  7024.                             updateSelection()
  7025.                         end
  7026.                     end)
  7027.  
  7028.                     obj:Refresh()
  7029.                 end
  7030.             end)
  7031.         end
  7032.  
  7033.         local function makeFrame(obj)
  7034.             local frame = create({
  7035.                 {1,"Frame",{BackgroundColor3=Color3.new(0.15686275064945,0.15686275064945,0.15686275064945),BorderSizePixel = 0,Position=UDim2.new(0.5,-300,0.5,-200),Size=UDim2.new(0,600,0,400),}},
  7036.             })
  7037.             local elems = {}
  7038.            
  7039.             local linesFrame = Instance.new("Frame")
  7040.             linesFrame.Name = "Lines"
  7041.             linesFrame.BackgroundTransparency = 1
  7042.             linesFrame.Size = UDim2.new(1,0,1,0)
  7043.             linesFrame.ClipsDescendants = true
  7044.             linesFrame.Parent = frame
  7045.            
  7046.             local lineNumbersLabel = Instance.new("TextLabel")
  7047.             lineNumbersLabel.Name = "LineNumbers"
  7048.             lineNumbersLabel.BackgroundTransparency = 1
  7049.             lineNumbersLabel.Font = Enum.Font.Code
  7050.             lineNumbersLabel.TextXAlignment = Enum.TextXAlignment.Right
  7051.             lineNumbersLabel.TextYAlignment = Enum.TextYAlignment.Top
  7052.             lineNumbersLabel.ClipsDescendants = true
  7053.             lineNumbersLabel.RichText = true
  7054.             lineNumbersLabel.Parent = frame
  7055.            
  7056.             local cursor = Instance.new("Frame")
  7057.             cursor.Name = "Cursor"
  7058.             cursor.BackgroundColor3 = Color3.fromRGB(220,220,220)
  7059.             cursor.BorderSizePixel = 0
  7060.             cursor.Parent = frame
  7061.            
  7062.             local editBox = Instance.new("TextBox")
  7063.             editBox.Name = "EditBox"
  7064.             editBox.MultiLine = true
  7065.             editBox.Visible = false
  7066.             editBox.Parent = frame
  7067.            
  7068.             lineTweens.Invis = tweenService:Create(cursor,TweenInfo.new(0.4,Enum.EasingStyle.Quart,Enum.EasingDirection.Out),{BackgroundTransparency = 1})
  7069.             lineTweens.Vis = tweenService:Create(cursor,TweenInfo.new(0.2,Enum.EasingStyle.Quart,Enum.EasingDirection.Out),{BackgroundTransparency = 0})
  7070.            
  7071.             elems.LinesFrame = linesFrame
  7072.             elems.LineNumbersLabel = lineNumbersLabel
  7073.             elems.Cursor = cursor
  7074.             elems.EditBox = editBox
  7075.             elems.ScrollCorner = create({{1,"Frame",{BackgroundColor3=Color3.new(0.15686275064945,0.15686275064945,0.15686275064945),BorderSizePixel=0,Name="ScrollCorner",Position=UDim2.new(1,-16,1,-16),Size=UDim2.new(0,16,0,16),Visible=false,}}})
  7076.            
  7077.             elems.ScrollCorner.Parent = frame
  7078.             linesFrame.InputBegan:Connect(function(input)
  7079.                 if input.UserInputType == Enum.UserInputType.MouseButton1 then
  7080.                     obj:SetEditing(true,input)
  7081.                 end
  7082.             end)
  7083.            
  7084.             obj.Frame = frame
  7085.             obj.Gui = frame
  7086.             obj.GuiElems = elems
  7087.             setupEditBox(obj)
  7088.             setupMouseSelection(obj)
  7089.            
  7090.             return frame
  7091.         end
  7092.        
  7093.         funcs.GetSelectionText = function(self)
  7094.             if not self:IsValidRange() then return "" end
  7095.            
  7096.             local selectionRange = self.SelectionRange
  7097.             local selX,selY = selectionRange[1][1], selectionRange[1][2]
  7098.             local sel2X,sel2Y = selectionRange[2][1], selectionRange[2][2]
  7099.             local deltaLines = sel2Y-selY
  7100.             local lines = self.Lines
  7101.  
  7102.             if not lines[selY+1] or not lines[sel2Y+1] then return "" end
  7103.  
  7104.             if deltaLines == 0 then
  7105.                 return self:ConvertText(lines[selY+1]:sub(selX+1,sel2X), false)
  7106.             end
  7107.  
  7108.             local leftSub = lines[selY+1]:sub(selX+1)
  7109.             local rightSub = lines[sel2Y+1]:sub(1,sel2X)
  7110.  
  7111.             local result = leftSub.."\n"
  7112.             for i = selY+1,sel2Y-1 do
  7113.                 result = result..lines[i+1].."\n"
  7114.             end
  7115.             result = result..rightSub
  7116.  
  7117.             return self:ConvertText(result,false)
  7118.         end
  7119.        
  7120.         funcs.SetCopyableSelection = function(self)
  7121.             local text = self:GetSelectionText()
  7122.             local editBox = self.GuiElems.EditBox
  7123.            
  7124.             self.EditBoxCopying = true
  7125.             editBox.Text = text
  7126.             editBox.SelectionStart = 1
  7127.             editBox.CursorPosition = #editBox.Text + 1
  7128.             self.EditBoxCopying = false
  7129.         end
  7130.        
  7131.         funcs.ConnectEditBoxEvent = function(self)
  7132.             if self.EditBoxEvent then
  7133.                 self.EditBoxEvent:Disconnect()
  7134.             end
  7135.            
  7136.             self.EditBoxEvent = service.UserInputService.InputBegan:Connect(function(input)
  7137.                 if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
  7138.                
  7139.                 local keycodes = Enum.KeyCode
  7140.                 local keycode = input.KeyCode
  7141.                
  7142.                 local function setupMove(key,func)
  7143.                     local endCon,finished
  7144.                     endCon = service.UserInputService.InputEnded:Connect(function(input)
  7145.                         if input.KeyCode ~= key then return end
  7146.                         endCon:Disconnect()
  7147.                         finished = true
  7148.                     end)
  7149.                     func()
  7150.                     Lib.FastWait(0.5)
  7151.                     while not finished do func() Lib.FastWait(0.03) end
  7152.                 end
  7153.                
  7154.                 if keycode == keycodes.Down then
  7155.                     setupMove(keycodes.Down,function()
  7156.                         self.CursorX = self.FloatCursorX
  7157.                         self.CursorY = self.CursorY + 1
  7158.                         self:UpdateCursor()
  7159.                         self:JumpToCursor()
  7160.                     end)
  7161.                 elseif keycode == keycodes.Up then
  7162.                     setupMove(keycodes.Up,function()
  7163.                         self.CursorX = self.FloatCursorX
  7164.                         self.CursorY = self.CursorY - 1
  7165.                         self:UpdateCursor()
  7166.                         self:JumpToCursor()
  7167.                     end)
  7168.                 elseif keycode == keycodes.Left then
  7169.                     setupMove(keycodes.Left,function()
  7170.                         local line = self.Lines[self.CursorY+1] or ""
  7171.                         self.CursorX = self.CursorX - 1 - (line:sub(self.CursorX-3,self.CursorX) == tabReplacement and 3 or 0)
  7172.                         if self.CursorX < 0 then
  7173.                             self.CursorY = self.CursorY - 1
  7174.                             local line2 = self.Lines[self.CursorY+1] or ""
  7175.                             self.CursorX = #line2
  7176.                         end
  7177.                         self.FloatCursorX = self.CursorX
  7178.                         self:UpdateCursor()
  7179.                         self:JumpToCursor()
  7180.                     end)
  7181.                 elseif keycode == keycodes.Right then
  7182.                     setupMove(keycodes.Right,function()
  7183.                         local line = self.Lines[self.CursorY+1] or ""
  7184.                         self.CursorX = self.CursorX + 1 + (line:sub(self.CursorX+1,self.CursorX+4) == tabReplacement and 3 or 0)
  7185.                         if self.CursorX > #line then
  7186.                             self.CursorY = self.CursorY + 1
  7187.                             self.CursorX = 0
  7188.                         end
  7189.                         self.FloatCursorX = self.CursorX
  7190.                         self:UpdateCursor()
  7191.                         self:JumpToCursor()
  7192.                     end)
  7193.                 elseif keycode == keycodes.Backspace then
  7194.                     setupMove(keycodes.Backspace,function()
  7195.                         local startRange,endRange
  7196.                         if self:IsValidRange() then
  7197.                             startRange = self.SelectionRange[1]
  7198.                             endRange = self.SelectionRange[2]
  7199.                         else
  7200.                             endRange = {self.CursorX,self.CursorY}
  7201.                         end
  7202.                        
  7203.                         if not startRange then
  7204.                             local line = self.Lines[self.CursorY+1] or ""
  7205.                             self.CursorX = self.CursorX - 1 - (line:sub(self.CursorX-3,self.CursorX) == tabReplacement and 3 or 0)
  7206.                             if self.CursorX < 0 then
  7207.                                 self.CursorY = self.CursorY - 1
  7208.                                 local line2 = self.Lines[self.CursorY+1] or ""
  7209.                                 self.CursorX = #line2
  7210.                             end
  7211.                             self.FloatCursorX = self.CursorX
  7212.                             self:UpdateCursor()
  7213.                        
  7214.                             startRange = startRange or {self.CursorX,self.CursorY}
  7215.                         end
  7216.                        
  7217.                         self:DeleteRange({startRange,endRange},false,true)
  7218.                         self:ResetSelection(true)
  7219.                         self:JumpToCursor()
  7220.                     end)
  7221.                 elseif keycode == keycodes.Delete then
  7222.                     setupMove(keycodes.Delete,function()
  7223.                         local startRange,endRange
  7224.                         if self:IsValidRange() then
  7225.                             startRange = self.SelectionRange[1]
  7226.                             endRange = self.SelectionRange[2]
  7227.                         else
  7228.                             startRange = {self.CursorX,self.CursorY}
  7229.                         end
  7230.  
  7231.                         if not endRange then
  7232.                             local line = self.Lines[self.CursorY+1] or ""
  7233.                             local endCursorX = self.CursorX + 1 + (line:sub(self.CursorX+1,self.CursorX+4) == tabReplacement and 3 or 0)
  7234.                             local endCursorY = self.CursorY
  7235.                             if endCursorX > #line then
  7236.                                 endCursorY = endCursorY + 1
  7237.                                 endCursorX = 0
  7238.                             end
  7239.                             self:UpdateCursor()
  7240.  
  7241.                             endRange = endRange or {endCursorX,endCursorY}
  7242.                         end
  7243.  
  7244.                         self:DeleteRange({startRange,endRange},false,true)
  7245.                         self:ResetSelection(true)
  7246.                         self:JumpToCursor()
  7247.                     end)
  7248.                 elseif service.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
  7249.                     if keycode == keycodes.A then
  7250.                         self.SelectionRange = {{0,0},{#self.Lines[#self.Lines],#self.Lines-1}}
  7251.                         self:SetCopyableSelection()
  7252.                         self:Refresh()
  7253.                     end
  7254.                 end
  7255.             end)
  7256.         end
  7257.        
  7258.         funcs.DisconnectEditBoxEvent = function(self)
  7259.             if self.EditBoxEvent then
  7260.                 self.EditBoxEvent:Disconnect()
  7261.             end
  7262.         end
  7263.        
  7264.         funcs.ResetSelection = function(self,norefresh)
  7265.             self.SelectionRange = {{-1,-1},{-1,-1}}
  7266.             if not norefresh then self:Refresh() end
  7267.         end
  7268.        
  7269.         funcs.IsValidRange = function(self,range)
  7270.             local selectionRange = range or self.SelectionRange
  7271.             local selX,selY = selectionRange[1][1], selectionRange[1][2]
  7272.             local sel2X,sel2Y = selectionRange[2][1], selectionRange[2][2]
  7273.  
  7274.             if selX == -1 or (selX == sel2X and selY == sel2Y) then return false end
  7275.  
  7276.             return true
  7277.         end
  7278.        
  7279.         funcs.DeleteRange = function(self,range,noprocess,updatemouse)
  7280.             range = range or self.SelectionRange
  7281.             if not self:IsValidRange(range) then return end
  7282.            
  7283.             local lines = self.Lines
  7284.             local selX,selY = range[1][1], range[1][2]
  7285.             local sel2X,sel2Y = range[2][1], range[2][2]
  7286.             local deltaLines = sel2Y-selY
  7287.            
  7288.             if not lines[selY+1] or not lines[sel2Y+1] then return end
  7289.            
  7290.             local leftSub = lines[selY+1]:sub(1,selX)
  7291.             local rightSub = lines[sel2Y+1]:sub(sel2X+1)
  7292.             lines[selY+1] = leftSub..rightSub
  7293.            
  7294.             local remove = table.remove
  7295.             for i = 1,deltaLines do
  7296.                 remove(lines,selY+2)
  7297.             end
  7298.            
  7299.             if range == self.SelectionRange then self.SelectionRange = {{-1,-1},{-1,-1}} end
  7300.             if updatemouse then
  7301.                 self.CursorX = selX
  7302.                 self.CursorY = selY
  7303.                 self:UpdateCursor()
  7304.             end
  7305.            
  7306.             if not noprocess then
  7307.                 self:ProcessTextChange()
  7308.             end
  7309.         end
  7310.        
  7311.         funcs.AppendText = function(self,text)
  7312.             self:DeleteRange(nil,true,true)
  7313.             local lines,cursorX,cursorY = self.Lines,self.CursorX,self.CursorY
  7314.             local line = lines[cursorY+1]
  7315.             local before = line:sub(1,cursorX)
  7316.             local after = line:sub(cursorX+1)
  7317.            
  7318.             text = text:gsub("\r\n","\n")
  7319.             text = self:ConvertText(text,true) -- Tab Convert
  7320.            
  7321.             local textLines = text:split("\n")
  7322.             local insert = table.insert
  7323.            
  7324.             for i = 1,#textLines do
  7325.                 local linePos = cursorY+i
  7326.                 if i > 1 then insert(lines,linePos,"") end
  7327.                
  7328.                 local textLine = textLines[i]
  7329.                 local newBefore = (i == 1 and before or "")
  7330.                 local newAfter = (i == #textLines and after or "")
  7331.            
  7332.                 lines[linePos] = newBefore..textLine..newAfter
  7333.             end
  7334.            
  7335.             if #textLines > 1 then cursorX = 0 end
  7336.            
  7337.             self:ProcessTextChange()
  7338.             self.CursorX = cursorX + #textLines[#textLines]
  7339.             self.CursorY = cursorY + #textLines-1
  7340.             self:UpdateCursor()
  7341.         end
  7342.        
  7343.         funcs.ScrollDelta = function(self,x,y)
  7344.             self.ScrollV:ScrollTo(self.ScrollV.Index + y)
  7345.             self.ScrollH:ScrollTo(self.ScrollH.Index + x)
  7346.         end
  7347.        
  7348.         -- x and y starts at 0
  7349.         funcs.TabAdjust = function(self,x,y)
  7350.             local lines = self.Lines
  7351.             local line = lines[y+1]
  7352.             x=x+1
  7353.            
  7354.             if line then
  7355.                 local left = line:sub(x-1,x-1)
  7356.                 local middle = line:sub(x,x)
  7357.                 local right = line:sub(x+1,x+1)
  7358.                 local selRange = (#left > 0 and left or " ") .. (#middle > 0 and middle or " ") .. (#right > 0 and right or " ")
  7359.  
  7360.                 for i,v in pairs(tabJumps) do
  7361.                     if selRange:find(i) then
  7362.                         return v
  7363.                     end
  7364.                 end
  7365.             end
  7366.             return 0
  7367.         end
  7368.        
  7369.         funcs.SetEditing = function(self,on,input)         
  7370.             self:UpdateCursor(input)
  7371.            
  7372.             if on then
  7373.                 if self.Editable then
  7374.                     self.GuiElems.EditBox.Text = ""
  7375.                     self.GuiElems.EditBox:CaptureFocus()
  7376.                 end
  7377.             else
  7378.                 self.GuiElems.EditBox:ReleaseFocus()
  7379.             end
  7380.         end
  7381.        
  7382.         funcs.CursorAnim = function(self,on)
  7383.             local cursor = self.GuiElems.Cursor
  7384.             local animTime = tick()
  7385.             self.LastAnimTime = animTime
  7386.            
  7387.             if not on then return end
  7388.            
  7389.             lineTweens.Invis:Cancel()
  7390.             lineTweens.Vis:Cancel()
  7391.             cursor.BackgroundTransparency = 0
  7392.            
  7393.             coroutine.wrap(function()
  7394.                 while self.Editable do
  7395.                     Lib.FastWait(0.5)
  7396.                     if self.LastAnimTime ~= animTime then return end
  7397.                     lineTweens.Invis:Play()
  7398.                     Lib.FastWait(0.4)
  7399.                     if self.LastAnimTime ~= animTime then return end
  7400.                     lineTweens.Vis:Play()
  7401.                     Lib.FastWait(0.2)
  7402.                 end
  7403.             end)()
  7404.         end
  7405.        
  7406.         funcs.MoveCursor = function(self,x,y)
  7407.             self.CursorX = x
  7408.             self.CursorY = y
  7409.             self:UpdateCursor()
  7410.             self:JumpToCursor()
  7411.         end
  7412.        
  7413.         funcs.JumpToCursor = function(self)
  7414.             self:Refresh()
  7415.         end
  7416.        
  7417.         funcs.UpdateCursor = function(self,input)
  7418.             local linesFrame = self.GuiElems.LinesFrame
  7419.             local cursor = self.GuiElems.Cursor        
  7420.             local hSize = math.max(0,linesFrame.AbsoluteSize.X)
  7421.             local vSize = math.max(0,linesFrame.AbsoluteSize.Y)
  7422.             local maxLines = math.ceil(vSize / self.FontSize)
  7423.             local maxCols = math.ceil(hSize / math.ceil(self.FontSize/2))
  7424.             local viewX,viewY = self.ViewX,self.ViewY
  7425.             local totalLinesStr = tostring(#self.Lines)
  7426.             local fontWidth = math.ceil(self.FontSize / 2)
  7427.             local linesOffset = #totalLinesStr*fontWidth + 4*fontWidth
  7428.            
  7429.             if input then
  7430.                 local linesFrame = self.GuiElems.LinesFrame
  7431.                 local frameX,frameY = linesFrame.AbsolutePosition.X,linesFrame.AbsolutePosition.Y
  7432.                 local mouseX,mouseY = input.Position.X,input.Position.Y
  7433.                 local fontSizeX,fontSizeY = math.ceil(self.FontSize/2),self.FontSize
  7434.  
  7435.                 self.CursorX = self.ViewX + math.round((mouseX - frameX) / fontSizeX)
  7436.                 self.CursorY = self.ViewY + math.floor((mouseY - frameY) / fontSizeY)
  7437.             end
  7438.            
  7439.             local cursorX,cursorY = self.CursorX,self.CursorY
  7440.            
  7441.             local line = self.Lines[cursorY+1] or ""
  7442.             if cursorX > #line then cursorX = #line
  7443.             elseif cursorX < 0 then cursorX = 0 end
  7444.            
  7445.             if cursorY >= #self.Lines then
  7446.                 cursorY = math.max(0,#self.Lines-1)
  7447.             elseif cursorY < 0 then
  7448.                 cursorY = 0
  7449.             end
  7450.            
  7451.             cursorX = cursorX + self:TabAdjust(cursorX,cursorY)
  7452.            
  7453.             -- Update modified
  7454.             self.CursorX = cursorX
  7455.             self.CursorY = cursorY
  7456.            
  7457.             local cursorVisible = (cursorX >= viewX) and (cursorY >= viewY) and (cursorX <= viewX + maxCols) and (cursorY <= viewY + maxLines)
  7458.             if cursorVisible then
  7459.                 local offX = (cursorX - viewX)
  7460.                 local offY = (cursorY - viewY)
  7461.                 cursor.Position = UDim2.new(0,linesOffset + offX*math.ceil(self.FontSize/2) - 1,0,offY*self.FontSize)
  7462.                 cursor.Size = UDim2.new(0,1,0,self.FontSize+2)
  7463.                 cursor.Visible = true
  7464.                 self:CursorAnim(true)
  7465.             else
  7466.                 cursor.Visible = false
  7467.             end
  7468.         end
  7469.  
  7470.         funcs.MapNewLines = function(self)
  7471.             local newLines = {}
  7472.             local count = 1
  7473.             local text = self.Text
  7474.             local find = string.find
  7475.             local init = 1
  7476.  
  7477.             local pos = find(text,"\n",init,true)
  7478.             while pos do
  7479.                 newLines[count] = pos
  7480.                 count = count + 1
  7481.                 init = pos + 1
  7482.                 pos = find(text,"\n",init,true)
  7483.             end
  7484.  
  7485.             self.NewLines = newLines
  7486.         end
  7487.  
  7488.         funcs.PreHighlight = function(self)
  7489.             local start = tick()
  7490.             local text = self.Text:gsub("\\\\","  ")
  7491.             --print("BACKSLASH SUB",tick()-start)
  7492.             local textLen = #text
  7493.             local found = {}
  7494.             local foundMap = {}
  7495.             local extras = {}
  7496.             local find = string.find
  7497.             local sub = string.sub
  7498.             self.ColoredLines = {}
  7499.  
  7500.             local function findAll(str,pattern,typ,raw)
  7501.                 local count = #found+1
  7502.                 local init = 1
  7503.                 local x,y,extra = find(str,pattern,init,raw)
  7504.                 while x do
  7505.                     found[count] = x
  7506.                     foundMap[x] = typ
  7507.                     if extra then
  7508.                         extras[x] = extra
  7509.                     end
  7510.  
  7511.                     count = count+1
  7512.                     init = y+1
  7513.                     x,y,extra = find(str,pattern,init,raw)
  7514.                 end
  7515.             end
  7516.             local start = tick()
  7517.             findAll(text,'"',1,true)
  7518.             findAll(text,"'",2,true)
  7519.             findAll(text,"%[(=*)%[",3)
  7520.             findAll(text,"--",4,true)
  7521.             table.sort(found)
  7522.  
  7523.             local newLines = self.NewLines
  7524.             local curLine = 0
  7525.             local lineTableCount = 1
  7526.             local lineStart = 0
  7527.             local lineEnd = 0
  7528.             local lastEnding = 0
  7529.             local foundHighlights = {}
  7530.  
  7531.             for i = 1,#found do
  7532.                 local pos = found[i]
  7533.                 if pos <= lastEnding then continue end
  7534.  
  7535.                 local ending = pos
  7536.                 local typ = foundMap[pos]
  7537.                 if typ == 1 then
  7538.                     ending = find(text,'"',pos+1,true)
  7539.                     while ending and sub(text,ending-1,ending-1) == "\\" do
  7540.                         ending = find(text,'"',ending+1,true)
  7541.                     end
  7542.                     if not ending then ending = textLen end
  7543.                 elseif typ == 2 then
  7544.                     ending = find(text,"'",pos+1,true)
  7545.                     while ending and sub(text,ending-1,ending-1) == "\\" do
  7546.                         ending = find(text,"'",ending+1,true)
  7547.                     end
  7548.                     if not ending then ending = textLen end
  7549.                 elseif typ == 3 then
  7550.                     _,ending = find(text,"]"..extras[pos].."]",pos+1,true)
  7551.                     if not ending then ending = textLen end
  7552.                 elseif typ == 4 then
  7553.                     local ahead = foundMap[pos+2]
  7554.  
  7555.                     if ahead == 3 then
  7556.                         _,ending = find(text,"]"..extras[pos+2].."]",pos+1,true)
  7557.                         if not ending then ending = textLen end
  7558.                     else
  7559.                         ending = find(text,"\n",pos+1,true) or textLen
  7560.                     end
  7561.                 end
  7562.  
  7563.                 while pos > lineEnd do
  7564.                     curLine = curLine + 1
  7565.                     --lineTableCount = 1
  7566.                     lineEnd = newLines[curLine] or textLen+1
  7567.                 end
  7568.                 while true do
  7569.                     local lineTable = foundHighlights[curLine]
  7570.                     if not lineTable then lineTable = {} foundHighlights[curLine] = lineTable end
  7571.                     lineTable[pos] = {typ,ending}
  7572.                     --lineTableCount = lineTableCount + 1
  7573.  
  7574.                     if ending > lineEnd then
  7575.                         curLine = curLine + 1
  7576.                         lineEnd = newLines[curLine] or textLen+1
  7577.                     else
  7578.                         break
  7579.                     end
  7580.                 end
  7581.  
  7582.                 lastEnding = ending
  7583.                 --if i < 200 then print(curLine) end
  7584.             end
  7585.             self.PreHighlights = foundHighlights
  7586.             --print(tick()-start)
  7587.             --print(#found,curLine)
  7588.         end
  7589.  
  7590.         funcs.HighlightLine = function(self,line)
  7591.             local cached = self.ColoredLines[line]
  7592.             if cached then return cached end
  7593.  
  7594.             local sub = string.sub
  7595.             local find = string.find
  7596.             local match = string.match
  7597.             local highlights = {}
  7598.             local preHighlights = self.PreHighlights[line] or {}
  7599.             local lineText = self.Lines[line] or ""
  7600.             local lineLen = #lineText
  7601.             local lastEnding = 0
  7602.             local currentType = 0
  7603.             local lastWord = nil
  7604.             local wordBeginsDotted = false
  7605.             local funcStatus = 0
  7606.             local lineStart = self.NewLines[line-1] or 0
  7607.  
  7608.             local preHighlightMap = {}
  7609.             for pos,data in next,preHighlights do
  7610.                 local relativePos = pos-lineStart
  7611.                 if relativePos < 1 then
  7612.                     currentType = data[1]
  7613.                     lastEnding = data[2] - lineStart
  7614.                     --warn(pos,data[2])
  7615.                 else
  7616.                     preHighlightMap[relativePos] = {data[1],data[2]-lineStart}
  7617.                 end
  7618.             end
  7619.  
  7620.             for col = 1,#lineText do
  7621.                 if col <= lastEnding then highlights[col] = currentType continue end
  7622.  
  7623.                 local pre = preHighlightMap[col]
  7624.                 if pre then
  7625.                     currentType = pre[1]
  7626.                     lastEnding = pre[2]
  7627.                     highlights[col] = currentType
  7628.                     wordBeginsDotted = false
  7629.                     lastWord = nil
  7630.                     funcStatus = 0
  7631.                 else
  7632.                     local char = sub(lineText,col,col)
  7633.                     if find(char,"[%a_]") then
  7634.                         local word = match(lineText,"[%a%d_]+",col)
  7635.                         local wordType = (keywords[word] and 7) or (builtIns[word] and 8)
  7636.  
  7637.                         lastEnding = col+#word-1
  7638.  
  7639.                         if wordType ~= 7 then
  7640.                             if wordBeginsDotted then
  7641.                                 local prevBuiltIn = lastWord and builtIns[lastWord]
  7642.                                 wordType = (prevBuiltIn and type(prevBuiltIn) == "table" and prevBuiltIn[word] and 8) or 10
  7643.                             end
  7644.  
  7645.                             if wordType ~= 8 then
  7646.                                 local x,y,br = find(lineText,"^%s*([%({\"'])",lastEnding+1)
  7647.                                 if x then
  7648.                                     wordType = (funcStatus > 0 and br == "(" and 16) or 9
  7649.                                     funcStatus = 0
  7650.                                 end
  7651.                             end
  7652.                         else
  7653.                             wordType = specialKeywordsTypes[word] or wordType
  7654.                             funcStatus = (word == "function" and 1 or 0)
  7655.                         end
  7656.  
  7657.                         lastWord = word
  7658.                         wordBeginsDotted = false
  7659.                         if funcStatus > 0 then funcStatus = 1 end
  7660.  
  7661.                         if wordType then
  7662.                             currentType = wordType
  7663.                             highlights[col] = currentType
  7664.                         else
  7665.                             currentType = nil
  7666.                         end
  7667.                     elseif find(char,"%p") then
  7668.                         local isDot = (char == ".")
  7669.                         local isNum = isDot and find(sub(lineText,col+1,col+1),"%d")
  7670.                         highlights[col] = (isNum and 6 or 5)
  7671.  
  7672.                         if not isNum then
  7673.                             local dotStr = isDot and match(lineText,"%.%.?%.?",col)
  7674.                             if dotStr and #dotStr > 1 then
  7675.                                 currentType = 5
  7676.                                 lastEnding = col+#dotStr-1
  7677.                                 wordBeginsDotted = false
  7678.                                 lastWord = nil
  7679.                                 funcStatus = 0
  7680.                             else
  7681.                                 if isDot then
  7682.                                     if wordBeginsDotted then
  7683.                                         lastWord = nil
  7684.                                     else
  7685.                                         wordBeginsDotted = true
  7686.                                     end
  7687.                                 else
  7688.                                     wordBeginsDotted = false
  7689.                                     lastWord = nil
  7690.                                 end
  7691.  
  7692.                                 funcStatus = ((isDot or char == ":") and funcStatus == 1 and 2) or 0
  7693.                             end
  7694.                         end
  7695.                     elseif find(char,"%d") then
  7696.                         local _,endPos = find(lineText,"%x+",col)
  7697.                         local endPart = sub(lineText,endPos,endPos+1)
  7698.                         if (endPart == "e+" or endPart == "e-") and find(sub(lineText,endPos+2,endPos+2),"%d") then
  7699.                             endPos = endPos + 1
  7700.                         end
  7701.                         currentType = 6
  7702.                         lastEnding = endPos
  7703.                         highlights[col] = 6
  7704.                         wordBeginsDotted = false
  7705.                         lastWord = nil
  7706.                         funcStatus = 0
  7707.                     else
  7708.                         highlights[col] = currentType
  7709.                         local _,endPos = find(lineText,"%s+",col)
  7710.                         if endPos then
  7711.                             lastEnding = endPos
  7712.                         end
  7713.                     end
  7714.                 end
  7715.             end
  7716.  
  7717.             self.ColoredLines[line] = highlights
  7718.             return highlights
  7719.         end
  7720.  
  7721.         funcs.Refresh = function(self)
  7722.             local start = tick()
  7723.  
  7724.             local linesFrame = self.Frame.Lines
  7725.             local hSize = math.max(0,linesFrame.AbsoluteSize.X)
  7726.             local vSize = math.max(0,linesFrame.AbsoluteSize.Y)
  7727.             local maxLines = math.ceil(vSize / self.FontSize)
  7728.             local maxCols = math.ceil(hSize / math.ceil(self.FontSize/2))
  7729.             local gsub = string.gsub
  7730.             local sub = string.sub
  7731.  
  7732.             local viewX,viewY = self.ViewX,self.ViewY
  7733.  
  7734.             local lineNumberStr = ""
  7735.  
  7736.             for row = 1,maxLines do
  7737.                 local lineFrame = self.LineFrames[row]
  7738.                 if not lineFrame then
  7739.                     lineFrame = Instance.new("Frame")
  7740.                     lineFrame.Name = "Line"
  7741.                     lineFrame.Position = UDim2.new(0,0,0,(row-1)*self.FontSize)
  7742.                     lineFrame.Size = UDim2.new(1,0,0,self.FontSize)
  7743.                     lineFrame.BorderSizePixel = 0
  7744.                     lineFrame.BackgroundTransparency = 1
  7745.                    
  7746.                     local selectionHighlight = Instance.new("Frame")
  7747.                     selectionHighlight.Name = "SelectionHighlight"
  7748.                     selectionHighlight.BorderSizePixel = 0
  7749.                     selectionHighlight.BackgroundColor3 = Settings.Theme.Syntax.SelectionBack
  7750.                     selectionHighlight.Parent = lineFrame
  7751.                    
  7752.                     local label = Instance.new("TextLabel")
  7753.                     label.Name = "Label"
  7754.                     label.BackgroundTransparency = 1
  7755.                     label.Font = Enum.Font.Code
  7756.                     label.TextSize = self.FontSize
  7757.                     label.Size = UDim2.new(1,0,0,self.FontSize)
  7758.                     label.RichText = true
  7759.                     label.TextXAlignment = Enum.TextXAlignment.Left
  7760.                     label.TextColor3 = self.Colors.Text
  7761.                     label.ZIndex = 2
  7762.                     label.Parent = lineFrame
  7763.                    
  7764.                     lineFrame.Parent = linesFrame
  7765.                     self.LineFrames[row] = lineFrame
  7766.                 end
  7767.  
  7768.                 local relaY = viewY + row
  7769.                 local lineText = self.Lines[relaY] or ""
  7770.                 local resText = ""
  7771.                 local highlights = self:HighlightLine(relaY)
  7772.                 local colStart = viewX + 1
  7773.  
  7774.                 local richTemplates = self.RichTemplates
  7775.                 local textTemplate = richTemplates.Text
  7776.                 local selectionTemplate = richTemplates.Selection
  7777.                 local curType = highlights[colStart]
  7778.                 local curTemplate = richTemplates[typeMap[curType]] or textTemplate
  7779.                
  7780.                 -- Selection Highlight
  7781.                 local selectionRange = self.SelectionRange
  7782.                 local selPos1 = selectionRange[1]
  7783.                 local selPos2 = selectionRange[2]
  7784.                 local selRow,selColumn = selPos1[2],selPos1[1]
  7785.                 local sel2Row,sel2Column = selPos2[2],selPos2[1]
  7786.                 local selRelaX,selRelaY = viewX,relaY-1
  7787.                
  7788.                 if selRelaY >= selPos1[2] and selRelaY <= selPos2[2] then
  7789.                     local fontSizeX = math.ceil(self.FontSize/2)
  7790.                     local posX = (selRelaY == selPos1[2] and selPos1[1] or 0) - viewX
  7791.                     local sizeX = (selRelaY == selPos2[2] and selPos2[1]-posX-viewX or maxCols+viewX)
  7792.  
  7793.                     lineFrame.SelectionHighlight.Position = UDim2.new(0,posX*fontSizeX,0,0)
  7794.                     lineFrame.SelectionHighlight.Size = UDim2.new(0,sizeX*fontSizeX,1,0)
  7795.                     lineFrame.SelectionHighlight.Visible = true
  7796.                 else
  7797.                     lineFrame.SelectionHighlight.Visible = false
  7798.                 end
  7799.                
  7800.                 -- Selection Text Color for first char
  7801.                 local inSelection = selRelaY >= selRow and selRelaY <= sel2Row and (selRelaY == selRow and viewX >= selColumn or selRelaY ~= selRow) and (selRelaY == sel2Row and viewX < sel2Column or selRelaY ~= sel2Row)
  7802.                 if inSelection then
  7803.                     curType = -999
  7804.                     curTemplate = selectionTemplate
  7805.                 end
  7806.                
  7807.                 for col = 2,maxCols do
  7808.                     local relaX = viewX + col
  7809.                     local selRelaX = relaX-1
  7810.                     local posType = highlights[relaX]
  7811.                    
  7812.                     -- Selection Text Color
  7813.                     local inSelection = selRelaY >= selRow and selRelaY <= sel2Row and (selRelaY == selRow and selRelaX >= selColumn or selRelaY ~= selRow) and (selRelaY == sel2Row and selRelaX < sel2Column or selRelaY ~= sel2Row)
  7814.                     if inSelection then
  7815.                         posType = -999
  7816.                     end
  7817.                    
  7818.                     if posType ~= curType then
  7819.                         local template = (inSelection and selectionTemplate) or richTemplates[typeMap[posType]] or textTemplate
  7820.                        
  7821.                         if template ~= curTemplate then
  7822.                             local nextText = gsub(sub(lineText,colStart,relaX-1),"['\"<>&]",richReplace)
  7823.                             resText = resText .. (curTemplate ~= textTemplate and (curTemplate .. nextText .. "</font>") or nextText)
  7824.                             colStart = relaX
  7825.                             curTemplate = template
  7826.                         end
  7827.                         curType = posType
  7828.                     end
  7829.                 end
  7830.  
  7831.                 local lastText = gsub(sub(lineText,colStart,viewX+maxCols),"['\"<>&]",richReplace)
  7832.                 --warn("SUB",colStart,viewX+maxCols-1)
  7833.                 if #lastText > 0 then
  7834.                     resText = resText .. (curTemplate ~= textTemplate and (curTemplate .. lastText .. "</font>") or lastText)
  7835.                 end
  7836.  
  7837.                 if self.Lines[relaY] then
  7838.                     lineNumberStr = lineNumberStr .. (relaY == self.CursorY and ("<b>"..relaY.."</b>\n") or relaY .. "\n")
  7839.                 end
  7840.  
  7841.                 lineFrame.Label.Text = resText
  7842.             end
  7843.  
  7844.             for i = maxLines+1,#self.LineFrames do
  7845.                 self.LineFrames[i]:Destroy()
  7846.                 self.LineFrames[i] = nil
  7847.             end
  7848.  
  7849.             self.Frame.LineNumbers.Text = lineNumberStr
  7850.             self:UpdateCursor()
  7851.  
  7852.             --print("REFRESH TIME",tick()-start)
  7853.         end
  7854.  
  7855.         funcs.UpdateView = function(self)
  7856.             local totalLinesStr = tostring(#self.Lines)
  7857.             local fontWidth = math.ceil(self.FontSize / 2)
  7858.             local linesOffset = #totalLinesStr*fontWidth + 4*fontWidth
  7859.  
  7860.             local linesFrame = self.Frame.Lines
  7861.             local hSize = linesFrame.AbsoluteSize.X
  7862.             local vSize = linesFrame.AbsoluteSize.Y
  7863.             local maxLines = math.ceil(vSize / self.FontSize)
  7864.             local totalWidth = self.MaxTextCols*fontWidth
  7865.             local scrollV = self.ScrollV
  7866.             local scrollH = self.ScrollH
  7867.  
  7868.             scrollV.VisibleSpace = maxLines
  7869.             scrollV.TotalSpace = #self.Lines + 1
  7870.             scrollH.VisibleSpace = math.ceil(hSize/fontWidth)
  7871.             scrollH.TotalSpace = self.MaxTextCols + 1
  7872.  
  7873.             scrollV.Gui.Visible = #self.Lines + 1 > maxLines
  7874.             scrollH.Gui.Visible = totalWidth > hSize
  7875.  
  7876.             local oldOffsets = self.FrameOffsets
  7877.             self.FrameOffsets = Vector2.new(scrollV.Gui.Visible and -16 or 0, scrollH.Gui.Visible and -16 or 0)
  7878.             if oldOffsets ~= self.FrameOffsets then
  7879.                 self:UpdateView()
  7880.             else
  7881.                 scrollV:ScrollTo(self.ViewY,true)
  7882.                 scrollH:ScrollTo(self.ViewX,true)
  7883.  
  7884.                 if scrollV.Gui.Visible and scrollH.Gui.Visible then
  7885.                     scrollV.Gui.Size = UDim2.new(0,16,1,-16)
  7886.                     scrollH.Gui.Size = UDim2.new(1,-16,0,16)
  7887.                     self.GuiElems.ScrollCorner.Visible = true
  7888.                 else
  7889.                     scrollV.Gui.Size = UDim2.new(0,16,1,0)
  7890.                     scrollH.Gui.Size = UDim2.new(1,0,0,16)
  7891.                     self.GuiElems.ScrollCorner.Visible = false
  7892.                 end
  7893.  
  7894.                 self.ViewY = scrollV.Index
  7895.                 self.ViewX = scrollH.Index
  7896.                 self.Frame.Lines.Position = UDim2.new(0,linesOffset,0,0)
  7897.                 self.Frame.Lines.Size = UDim2.new(1,-linesOffset+oldOffsets.X,1,oldOffsets.Y)
  7898.                 self.Frame.LineNumbers.Position = UDim2.new(0,fontWidth,0,0)
  7899.                 self.Frame.LineNumbers.Size = UDim2.new(0,#totalLinesStr*fontWidth,1,oldOffsets.Y)
  7900.                 self.Frame.LineNumbers.TextSize = self.FontSize
  7901.             end
  7902.         end
  7903.  
  7904.         funcs.ProcessTextChange = function(self)
  7905.             local maxCols = 0
  7906.             local lines = self.Lines
  7907.            
  7908.             for i = 1,#lines do
  7909.                 local lineLen = #lines[i]
  7910.                 if lineLen > maxCols then
  7911.                     maxCols = lineLen
  7912.                 end
  7913.             end
  7914.            
  7915.             self.MaxTextCols = maxCols
  7916.             self:UpdateView()  
  7917.             self.Text = table.concat(self.Lines,"\n")
  7918.             self:MapNewLines()
  7919.             self:PreHighlight()
  7920.             self:Refresh()
  7921.             --self.TextChanged:Fire()
  7922.         end
  7923.        
  7924.         funcs.ConvertText = function(self,text,toEditor)
  7925.             if toEditor then
  7926.                 return text:gsub("\t",(" %s%s "):format(tabSub,tabSub))
  7927.             else
  7928.                 return text:gsub((" %s%s "):format(tabSub,tabSub),"\t")
  7929.             end
  7930.         end
  7931.  
  7932.         funcs.GetText = function(self) -- TODO: better (use new tab format)
  7933.             local source = table.concat(self.Lines,"\n")
  7934.             return self:ConvertText(source,false) -- Tab Convert
  7935.         end
  7936.  
  7937.         funcs.SetText = function(self,txt)
  7938.             txt = self:ConvertText(txt,true) -- Tab Convert
  7939.             local lines = self.Lines
  7940.             table.clear(lines)
  7941.             local count = 1
  7942.  
  7943.             for line in txt:gmatch("([^\n\r]*)[\n\r]?") do
  7944.                 local len = #line
  7945.                 lines[count] = line
  7946.                 count = count + 1
  7947.             end
  7948.            
  7949.             self:ProcessTextChange()
  7950.         end
  7951.  
  7952.         funcs.MakeRichTemplates = function(self)
  7953.             local floor = math.floor
  7954.             local templates = {}
  7955.  
  7956.             for name,color in pairs(self.Colors) do
  7957.                 templates[name] = ('<font color="rgb(%s,%s,%s)">'):format(floor(color.r*255),floor(color.g*255),floor(color.b*255))
  7958.             end
  7959.  
  7960.             self.RichTemplates = templates
  7961.         end
  7962.  
  7963.         funcs.ApplyTheme = function(self)
  7964.             local colors = Settings.Theme.Syntax
  7965.             self.Colors = colors
  7966.             self.Frame.LineNumbers.TextColor3 = colors.Text
  7967.             self.Frame.BackgroundColor3 = colors.Background
  7968.         end
  7969.  
  7970.         local mt = {__index = funcs}
  7971.  
  7972.         local function new()
  7973.             if not builtInInited then initBuiltIn() end
  7974.  
  7975.             local scrollV = Lib.ScrollBar.new()
  7976.             local scrollH = Lib.ScrollBar.new(true)
  7977.             scrollH.Gui.Position = UDim2.new(0,0,1,-16)
  7978.             local obj = setmetatable({
  7979.                 FontSize = 15,
  7980.                 ViewX = 0,
  7981.                 ViewY = 0,
  7982.                 Colors = Settings.Theme.Syntax,
  7983.                 ColoredLines = {},
  7984.                 Lines = {""},
  7985.                 LineFrames = {},
  7986.                 Editable = true,
  7987.                 Editing = false,
  7988.                 CursorX = 0,
  7989.                 CursorY = 0,
  7990.                 FloatCursorX = 0,
  7991.                 Text = "",
  7992.                 PreHighlights = {},
  7993.                 SelectionRange = {{-1,-1},{-1,-1}},
  7994.                 NewLines = {},
  7995.                 FrameOffsets = Vector2.new(0,0),
  7996.                 MaxTextCols = 0,
  7997.                 ScrollV = scrollV,
  7998.                 ScrollH = scrollH
  7999.             },mt)
  8000.  
  8001.             scrollV.WheelIncrement = 3
  8002.             scrollH.Increment = 2
  8003.             scrollH.WheelIncrement = 7
  8004.  
  8005.             scrollV.Scrolled:Connect(function()
  8006.                 obj.ViewY = scrollV.Index
  8007.                 obj:Refresh()
  8008.             end)
  8009.  
  8010.             scrollH.Scrolled:Connect(function()
  8011.                 obj.ViewX = scrollH.Index
  8012.                 obj:Refresh()
  8013.             end)
  8014.  
  8015.             makeFrame(obj)
  8016.             obj:MakeRichTemplates()
  8017.             obj:ApplyTheme()
  8018.             scrollV:SetScrollFrame(obj.Frame.Lines)
  8019.             scrollV.Gui.Parent = obj.Frame
  8020.             scrollH.Gui.Parent = obj.Frame
  8021.  
  8022.             obj:UpdateView()
  8023.             obj.Frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
  8024.                 obj:UpdateView()
  8025.                 obj:Refresh()
  8026.             end)
  8027.  
  8028.             return obj
  8029.         end
  8030.  
  8031.         return {new = new}
  8032.     end)()
  8033.  
  8034.     Lib.Checkbox = (function()
  8035.         local funcs = {}
  8036.         local c3 = Color3.fromRGB
  8037.         local v2 = Vector2.new
  8038.         local ud2s = UDim2.fromScale
  8039.         local ud2o = UDim2.fromOffset
  8040.         local ud = UDim.new
  8041.         local max = math.max
  8042.         local new = Instance.new
  8043.         local TweenSize = new("Frame").TweenSize
  8044.         local ti = TweenInfo.new
  8045.         local delay = delay
  8046.  
  8047.         local function ripple(object, color)
  8048.             local circle = new('Frame')
  8049.             circle.BackgroundColor3 = color
  8050.             circle.BackgroundTransparency = 0.75
  8051.             circle.BorderSizePixel = 0
  8052.             circle.AnchorPoint = v2(0.5, 0.5)
  8053.             circle.Size = ud2o()
  8054.             circle.Position = ud2s(0.5, 0.5)
  8055.             circle.Parent = object
  8056.             local rounding = new('UICorner')
  8057.             rounding.CornerRadius = ud(1)
  8058.             rounding.Parent = circle
  8059.  
  8060.             local abssz = object.AbsoluteSize
  8061.             local size = max(abssz.X, abssz.Y) * 5/3
  8062.  
  8063.             TweenSize(circle, ud2o(size, size), "Out", "Quart", 0.4)
  8064.             service.TweenService:Create(circle, ti(0.4, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {BackgroundTransparency = 1}):Play()
  8065.  
  8066.             service.Debris:AddItem(circle, 0.4)
  8067.         end
  8068.  
  8069.         local function initGui(self,frame)
  8070.             local checkbox = frame or create({
  8071.                 {1,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="Checkbox",Position=UDim2.new(0,3,0,3),Size=UDim2.new(0,16,0,16),}},
  8072.                 {2,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ripples",Parent={1},Size=UDim2.new(1,0,1,0),}},
  8073.                 {3,"Frame",{BackgroundColor3=Color3.new(0.10196078568697,0.10196078568697,0.10196078568697),BorderSizePixel=0,Name="outline",Parent={1},Size=UDim2.new(0,16,0,16),}},
  8074.                 {4,"Frame",{BackgroundColor3=Color3.new(0.14117647707462,0.14117647707462,0.14117647707462),BorderSizePixel=0,Name="filler",Parent={3},Position=UDim2.new(0,1,0,1),Size=UDim2.new(0,14,0,14),}},
  8075.                 {5,"Frame",{BackgroundColor3=Color3.new(0.90196084976196,0.90196084976196,0.90196084976196),BorderSizePixel=0,Name="top",Parent={4},Size=UDim2.new(0,16,0,0),}},
  8076.                 {6,"Frame",{AnchorPoint=Vector2.new(0,1),BackgroundColor3=Color3.new(0.90196084976196,0.90196084976196,0.90196084976196),BorderSizePixel=0,Name="bottom",Parent={4},Position=UDim2.new(0,0,0,14),Size=UDim2.new(0,16,0,0),}},
  8077.                 {7,"Frame",{BackgroundColor3=Color3.new(0.90196084976196,0.90196084976196,0.90196084976196),BorderSizePixel=0,Name="left",Parent={4},Size=UDim2.new(0,0,0,16),}},
  8078.                 {8,"Frame",{AnchorPoint=Vector2.new(1,0),BackgroundColor3=Color3.new(0.90196084976196,0.90196084976196,0.90196084976196),BorderSizePixel=0,Name="right",Parent={4},Position=UDim2.new(0,14,0,0),Size=UDim2.new(0,0,0,16),}},
  8079.                 {9,"Frame",{AnchorPoint=Vector2.new(0.5,0.5),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,ClipsDescendants=true,Name="checkmark",Parent={4},Position=UDim2.new(0.5,0,0.5,0),Size=UDim2.new(0,0,0,20),}},
  8080.                 {10,"ImageLabel",{AnchorPoint=Vector2.new(0.5,0.5),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Image="rbxassetid://6234266378",Parent={9},Position=UDim2.new(0.5,0,0.5,0),ScaleType=3,Size=UDim2.new(0,15,0,11),}},
  8081.                 {11,"ImageLabel",{AnchorPoint=Vector2.new(0.5,0.5),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://6401617475",ImageColor3=Color3.new(0.20784313976765,0.69803923368454,0.98431372642517),Name="checkmark2",Parent={4},Position=UDim2.new(0.5,0,0.5,0),Size=UDim2.new(0,12,0,12),Visible=false,}},
  8082.                 {12,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://6425281788",ImageTransparency=0.20000000298023,Name="middle",Parent={4},ScaleType=2,Size=UDim2.new(1,0,1,0),TileSize=UDim2.new(0,2,0,2),Visible=false,}},
  8083.                 {13,"UICorner",{CornerRadius=UDim.new(0,2),Parent={3},}},
  8084.             })
  8085.             local outline = checkbox.outline
  8086.             local filler = outline.filler
  8087.             local checkmark = filler.checkmark
  8088.             local ripples_container = checkbox.ripples
  8089.  
  8090.             -- walls
  8091.             local top, bottom, left, right = filler.top, filler.bottom, filler.left, filler.right
  8092.  
  8093.             self.Gui = checkbox
  8094.             self.GuiElems = {
  8095.                 Top = top,
  8096.                 Bottom = bottom,
  8097.                 Left = left,
  8098.                 Right = right,
  8099.                 Outline = outline,
  8100.                 Filler = filler,
  8101.                 Checkmark = checkmark,
  8102.                 Checkmark2 = filler.checkmark2,
  8103.                 Middle = filler.middle
  8104.             }
  8105.  
  8106.             checkbox.InputBegan:Connect(function(i)
  8107.                 if i.UserInputType == Enum.UserInputType.MouseButton1 then
  8108.                     local release
  8109.                     release = service.UserInputService.InputEnded:Connect(function(input)
  8110.                         if input.UserInputType == Enum.UserInputType.MouseButton1 then
  8111.                             release:Disconnect()
  8112.  
  8113.                             if Lib.CheckMouseInGui(checkbox) then
  8114.                                 if self.Style == 0 then
  8115.                                     ripple(ripples_container, self.Disabled and self.Colors.Disabled or self.Colors.Primary)
  8116.                                 end
  8117.  
  8118.                                 if not self.Disabled then
  8119.                                     self:SetState(not self.Toggled,true)
  8120.                                 else
  8121.                                     self:Paint()
  8122.                                 end
  8123.  
  8124.                                 self.OnInput:Fire()
  8125.                             end
  8126.                         end
  8127.                     end)
  8128.                 end
  8129.             end)
  8130.  
  8131.             self:Paint()
  8132.         end
  8133.  
  8134.         funcs.Collapse = function(self,anim)
  8135.             local guiElems = self.GuiElems
  8136.             if anim then
  8137.                 TweenSize(guiElems.Top, ud2o(14, 14), "In", "Quart", 4/15, true)
  8138.                 TweenSize(guiElems.Bottom, ud2o(14, 14), "In", "Quart", 4/15, true)
  8139.                 TweenSize(guiElems.Left, ud2o(14, 14), "In", "Quart", 4/15, true)
  8140.                 TweenSize(guiElems.Right, ud2o(14, 14), "In", "Quart", 4/15, true)
  8141.             else
  8142.                 guiElems.Top.Size = ud2o(14, 14)
  8143.                 guiElems.Bottom.Size = ud2o(14, 14)
  8144.                 guiElems.Left.Size = ud2o(14, 14)
  8145.                 guiElems.Right.Size = ud2o(14, 14)
  8146.             end
  8147.         end
  8148.  
  8149.         funcs.Expand = function(self,anim)
  8150.             local guiElems = self.GuiElems
  8151.             if anim then
  8152.                 TweenSize(guiElems.Top, ud2o(14, 0), "InOut", "Quart", 4/15, true)
  8153.                 TweenSize(guiElems.Bottom, ud2o(14, 0), "InOut", "Quart", 4/15, true)
  8154.                 TweenSize(guiElems.Left, ud2o(0, 14), "InOut", "Quart", 4/15, true)
  8155.                 TweenSize(guiElems.Right, ud2o(0, 14), "InOut", "Quart", 4/15, true)
  8156.             else
  8157.                 guiElems.Top.Size = ud2o(14, 0)
  8158.                 guiElems.Bottom.Size = ud2o(14, 0)
  8159.                 guiElems.Left.Size = ud2o(0, 14)
  8160.                 guiElems.Right.Size = ud2o(0, 14)
  8161.             end
  8162.         end
  8163.  
  8164.         funcs.Paint = function(self)
  8165.             local guiElems = self.GuiElems
  8166.  
  8167.             if self.Style == 0 then
  8168.                 local color_base = self.Disabled and self.Colors.Disabled
  8169.                 guiElems.Outline.BackgroundColor3 = color_base or (self.Toggled and self.Colors.Primary) or self.Colors.Secondary
  8170.                 local walls_color = color_base or self.Colors.Primary
  8171.                 guiElems.Top.BackgroundColor3 = walls_color
  8172.                 guiElems.Bottom.BackgroundColor3 = walls_color
  8173.                 guiElems.Left.BackgroundColor3 = walls_color
  8174.                 guiElems.Right.BackgroundColor3 = walls_color
  8175.             else
  8176.                 guiElems.Outline.BackgroundColor3 = self.Disabled and self.Colors.Disabled or self.Colors.Secondary
  8177.                 guiElems.Filler.BackgroundColor3 = self.Disabled and self.Colors.DisabledBackground or self.Colors.Background
  8178.                 guiElems.Checkmark2.ImageColor3 = self.Disabled and self.Colors.DisabledCheck or self.Colors.Primary
  8179.             end
  8180.         end
  8181.  
  8182.         funcs.SetState = function(self,val,anim)
  8183.             self.Toggled = val
  8184.  
  8185.             if self.OutlineColorTween then self.OutlineColorTween:Cancel() end
  8186.             local setStateTime = tick()
  8187.             self.LastSetStateTime = setStateTime
  8188.  
  8189.             if self.Toggled then
  8190.                 if self.Style == 0 then
  8191.                     if anim then
  8192.                         self.OutlineColorTween = service.TweenService:Create(self.GuiElems.Outline, ti(4/15, Enum.EasingStyle.Circular, Enum.EasingDirection.Out), {BackgroundColor3 = self.Colors.Primary})
  8193.                         self.OutlineColorTween:Play()
  8194.                         delay(0.15, function()
  8195.                             if setStateTime ~= self.LastSetStateTime then return end
  8196.                             self:Paint()
  8197.                             TweenSize(self.GuiElems.Checkmark, ud2o(14, 20), "Out", "Bounce", 2/15, true)
  8198.                         end)
  8199.                     else
  8200.                         self.GuiElems.Outline.BackgroundColor3 = self.Colors.Primary
  8201.                         self:Paint()
  8202.                         self.GuiElems.Checkmark.Size = ud2o(14, 20)
  8203.                     end
  8204.                     self:Collapse(anim)
  8205.                 else
  8206.                     self:Paint()
  8207.                     self.GuiElems.Checkmark2.Visible = true
  8208.                     self.GuiElems.Middle.Visible = false
  8209.                 end
  8210.             else
  8211.                 if self.Style == 0 then
  8212.                     if anim then
  8213.                         self.OutlineColorTween = service.TweenService:Create(self.GuiElems.Outline, ti(4/15, Enum.EasingStyle.Circular, Enum.EasingDirection.In), {BackgroundColor3 = self.Colors.Secondary})
  8214.                         self.OutlineColorTween:Play()
  8215.                         delay(0.15, function()
  8216.                             if setStateTime ~= self.LastSetStateTime then return end
  8217.                             self:Paint()
  8218.                             TweenSize(self.GuiElems.Checkmark, ud2o(0, 20), "Out", "Quad", 1/15, true)
  8219.                         end)
  8220.                     else
  8221.                         self.GuiElems.Outline.BackgroundColor3 = self.Colors.Secondary
  8222.                         self:Paint()
  8223.                         self.GuiElems.Checkmark.Size = ud2o(0, 20)
  8224.                     end
  8225.                     self:Expand(anim)
  8226.                 else
  8227.                     self:Paint()
  8228.                     self.GuiElems.Checkmark2.Visible = false
  8229.                     self.GuiElems.Middle.Visible = self.Toggled == nil
  8230.                 end
  8231.             end
  8232.         end
  8233.  
  8234.         local mt = {__index = funcs}
  8235.  
  8236.         local function new(style)
  8237.             local obj = setmetatable({
  8238.                 Toggled = false,
  8239.                 Disabled = false,
  8240.                 OnInput = Lib.Signal.new(),
  8241.                 Style = style or 0,
  8242.                 Colors = {
  8243.                     Background = c3(36,36,36),
  8244.                     Primary = c3(49,176,230),
  8245.                     Secondary = c3(25,25,25),
  8246.                     Disabled = c3(64,64,64),
  8247.                     DisabledBackground = c3(52,52,52),
  8248.                     DisabledCheck = c3(80,80,80)
  8249.                 }
  8250.             },mt)
  8251.             initGui(obj)
  8252.             return obj
  8253.         end
  8254.  
  8255.         local function fromFrame(frame)
  8256.             local obj = setmetatable({
  8257.                 Toggled = false,
  8258.                 Disabled = false,
  8259.                 Colors = {
  8260.                     Background = c3(36,36,36),
  8261.                     Primary = c3(49,176,230),
  8262.                     Secondary = c3(25,25,25),
  8263.                     Disabled = c3(64,64,64),
  8264.                     DisabledBackground = c3(52,52,52)
  8265.                 }
  8266.             },mt)
  8267.             initGui(obj,frame)
  8268.             return obj
  8269.         end
  8270.  
  8271.         return {new = new, fromFrame}
  8272.     end)()
  8273.  
  8274.     Lib.BrickColorPicker = (function()
  8275.         local funcs = {}
  8276.         local paletteCount = 0
  8277.         local mouse = service.Players.LocalPlayer:GetMouse()
  8278.         local hexStartX = 4
  8279.         local hexSizeX = 27
  8280.         local hexTriangleStart = 1
  8281.         local hexTriangleSize = 8
  8282.  
  8283.         local bottomColors = {
  8284.             Color3.fromRGB(17,17,17),
  8285.             Color3.fromRGB(99,95,98),
  8286.             Color3.fromRGB(163,162,165),
  8287.             Color3.fromRGB(205,205,205),
  8288.             Color3.fromRGB(223,223,222),
  8289.             Color3.fromRGB(237,234,234),
  8290.             Color3.fromRGB(27,42,53),
  8291.             Color3.fromRGB(91,93,105),
  8292.             Color3.fromRGB(159,161,172),
  8293.             Color3.fromRGB(202,203,209),
  8294.             Color3.fromRGB(231,231,236),
  8295.             Color3.fromRGB(248,248,248)
  8296.         }
  8297.  
  8298.         local function isMouseInHexagon(hex)
  8299.             local relativeX = mouse.X - hex.AbsolutePosition.X
  8300.             local relativeY = mouse.Y - hex.AbsolutePosition.Y
  8301.             if relativeX >= hexStartX and relativeX < hexStartX + hexSizeX then
  8302.                 relativeX = relativeX - 4
  8303.                 local relativeWidth = (13-math.min(relativeX,26 - relativeX))/13
  8304.                 if relativeY >= hexTriangleStart + hexTriangleSize*relativeWidth and relativeY < hex.AbsoluteSize.Y - hexTriangleStart - hexTriangleSize*relativeWidth then
  8305.                     return true
  8306.                 end
  8307.             end
  8308.  
  8309.             return false
  8310.         end
  8311.  
  8312.         local function hexInput(self,hex,color)
  8313.             hex.InputBegan:Connect(function(input)
  8314.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and isMouseInHexagon(hex) then
  8315.                     self.OnSelect:Fire(color)
  8316.                     self:Close()
  8317.                 end
  8318.             end)
  8319.  
  8320.             hex.InputChanged:Connect(function(input)
  8321.                 if input.UserInputType == Enum.UserInputType.MouseMovement and isMouseInHexagon(hex) then
  8322.                     self.OnPreview:Fire(color)
  8323.                 end
  8324.             end)
  8325.         end
  8326.  
  8327.         local function createGui(self)
  8328.             local gui = create({
  8329.                 {1,"ScreenGui",{Name="BrickColor",}},
  8330.                 {2,"Frame",{Active=true,BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.1294117718935,0.1294117718935,0.1294117718935),Parent={1},Position=UDim2.new(0.40000000596046,0,0.40000000596046,0),Size=UDim2.new(0,337,0,380),}},
  8331.                 {3,"TextButton",{BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),BorderSizePixel=0,Font=3,Name="MoreColors",Parent={2},Position=UDim2.new(0,5,1,-30),Size=UDim2.new(1,-10,0,25),Text="More Colors",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  8332.                 {4,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Image="rbxassetid://1281023007",ImageColor3=Color3.new(0.33333334326744,0.33333334326744,0.49803924560547),Name="Hex",Parent={2},Size=UDim2.new(0,35,0,35),Visible=false,}},
  8333.             })
  8334.             local colorFrame = gui.Frame
  8335.             local hex = colorFrame.Hex
  8336.  
  8337.             for row = 1,13 do
  8338.                 local columns = math.min(row,14-row)+6
  8339.                 for column = 1,columns do
  8340.                     local nextColor = BrickColor.palette(paletteCount).Color
  8341.                     local newHex = hex:Clone()
  8342.                     newHex.Position = UDim2.new(0, (column-1)*25-(columns-7)*13+3*26 + 1, 0, (row-1)*23 + 4)
  8343.                     newHex.ImageColor3 = nextColor
  8344.                     newHex.Visible = true
  8345.                     hexInput(self,newHex,nextColor)
  8346.                     newHex.Parent = colorFrame
  8347.                     paletteCount = paletteCount + 1
  8348.                 end
  8349.             end
  8350.  
  8351.             for column = 1,12 do
  8352.                 local nextColor = bottomColors[column]
  8353.                 local newHex = hex:Clone()
  8354.                 newHex.Position = UDim2.new(0, (column-1)*25-(12-7)*13+3*26 + 3, 0, 308)
  8355.                 newHex.ImageColor3 = nextColor
  8356.                 newHex.Visible = true
  8357.                 hexInput(self,newHex,nextColor)
  8358.                 newHex.Parent = colorFrame
  8359.                 paletteCount = paletteCount + 1
  8360.             end
  8361.  
  8362.             colorFrame.MoreColors.MouseButton1Click:Connect(function()
  8363.                 self.OnMoreColors:Fire()
  8364.                 self:Close()
  8365.             end)
  8366.  
  8367.             self.Gui = gui
  8368.         end
  8369.  
  8370.         funcs.SetMoreColorsVisible = function(self,vis)
  8371.             local colorFrame = self.Gui.Frame
  8372.             colorFrame.Size = UDim2.new(0,337,0,380 - (not vis and 33 or 0))
  8373.             colorFrame.MoreColors.Visible = vis
  8374.         end
  8375.  
  8376.         funcs.Show = function(self,x,y,prevColor)
  8377.             self.PrevColor = prevColor or self.PrevColor
  8378.  
  8379.             local reverseY = false
  8380.  
  8381.             local x,y = x or mouse.X, y or mouse.Y
  8382.             local maxX,maxY = mouse.ViewSizeX,mouse.ViewSizeY
  8383.             Lib.ShowGui(self.Gui)
  8384.             local sizeX,sizeY = self.Gui.Frame.AbsoluteSize.X,self.Gui.Frame.AbsoluteSize.Y
  8385.  
  8386.             if x + sizeX > maxX then x = self.ReverseX and x - sizeX or maxX - sizeX end
  8387.             if y + sizeY > maxY then reverseY = true end
  8388.  
  8389.             local closable = false
  8390.             if self.CloseEvent then self.CloseEvent:Disconnect() end
  8391.             self.CloseEvent = service.UserInputService.InputBegan:Connect(function(input)
  8392.                 if not closable or input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  8393.  
  8394.                 if not Lib.CheckMouseInGui(self.Gui.Frame) then
  8395.                     self.CloseEvent:Disconnect()
  8396.                     self:Close()
  8397.                 end
  8398.             end)
  8399.  
  8400.             if reverseY then
  8401.                 local newY = y - sizeY - (self.ReverseYOffset or 0)
  8402.                 y = newY >= 0 and newY or 0
  8403.             end
  8404.  
  8405.             self.Gui.Frame.Position = UDim2.new(0,x,0,y)
  8406.  
  8407.             Lib.FastWait()
  8408.             closable = true
  8409.         end
  8410.  
  8411.         funcs.Close = function(self)
  8412.             self.Gui.Parent = nil
  8413.             self.OnCancel:Fire()
  8414.         end
  8415.  
  8416.         local mt = {__index = funcs}
  8417.  
  8418.         local function new()
  8419.             local obj = setmetatable({
  8420.                 OnPreview = Lib.Signal.new(),
  8421.                 OnSelect = Lib.Signal.new(),
  8422.                 OnCancel = Lib.Signal.new(),
  8423.                 OnMoreColors = Lib.Signal.new(),
  8424.                 PrevColor = Color3.new(0,0,0)
  8425.             },mt)
  8426.             createGui(obj)
  8427.             return obj
  8428.         end
  8429.  
  8430.         return {new = new}
  8431.     end)()
  8432.  
  8433.     Lib.ColorPicker = (function() -- TODO: Convert to newer class model
  8434.         local funcs = {}
  8435.  
  8436.         local function new()
  8437.             local newMt = setmetatable({},{})
  8438.  
  8439.             newMt.OnSelect = Lib.Signal.new()
  8440.             newMt.OnCancel = Lib.Signal.new()
  8441.             newMt.OnPreview = Lib.Signal.new()
  8442.  
  8443.             local guiContents = create({
  8444.                 {1,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,ClipsDescendants=true,Name="Content",Position=UDim2.new(0,0,0,20),Size=UDim2.new(1,0,1,-20),}},
  8445.                 {2,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="BasicColors",Parent={1},Position=UDim2.new(0,5,0,5),Size=UDim2.new(0,180,0,200),}},
  8446.                 {3,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={2},Position=UDim2.new(0,0,0,-5),Size=UDim2.new(1,0,0,26),Text="Basic Colors",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8447.                 {4,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Blue",Parent={1},Position=UDim2.new(1,-63,0,255),Size=UDim2.new(0,52,0,16),}},
  8448.                 {5,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={4},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8449.                 {6,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={5},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8450.                 {7,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={6},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8451.                 {8,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={7},Size=UDim2.new(0,16,0,8),}},
  8452.                 {9,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={8},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8453.                 {10,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={8},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8454.                 {11,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={8},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8455.                 {12,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={6},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8456.                 {13,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={12},Size=UDim2.new(0,16,0,8),}},
  8457.                 {14,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={13},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8458.                 {15,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={13},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8459.                 {16,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={13},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8460.                 {17,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={4},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Blue:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8461.                 {18,"Frame",{BackgroundColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),BorderSizePixel=0,ClipsDescendants=true,Name="ColorSpaceFrame",Parent={1},Position=UDim2.new(1,-261,0,4),Size=UDim2.new(0,222,0,202),}},
  8462.                 {19,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),BorderSizePixel=0,Image="rbxassetid://1072518406",Name="ColorSpace",Parent={18},Position=UDim2.new(0,1,0,1),Size=UDim2.new(0,220,0,200),}},
  8463.                 {20,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="Scope",Parent={19},Position=UDim2.new(0,210,0,190),Size=UDim2.new(0,20,0,20),}},
  8464.                 {21,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Name="Line",Parent={20},Position=UDim2.new(0,9,0,0),Size=UDim2.new(0,2,0,20),}},
  8465.                 {22,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Name="Line",Parent={20},Position=UDim2.new(0,0,0,9),Size=UDim2.new(0,20,0,2),}},
  8466.                 {23,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="CustomColors",Parent={1},Position=UDim2.new(0,5,0,210),Size=UDim2.new(0,180,0,90),}},
  8467.                 {24,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={23},Size=UDim2.new(1,0,0,20),Text="Custom Colors (RC = Set)",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8468.                 {25,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Green",Parent={1},Position=UDim2.new(1,-63,0,233),Size=UDim2.new(0,52,0,16),}},
  8469.                 {26,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={25},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8470.                 {27,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={26},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8471.                 {28,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={27},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8472.                 {29,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={28},Size=UDim2.new(0,16,0,8),}},
  8473.                 {30,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={29},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8474.                 {31,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={29},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8475.                 {32,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={29},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8476.                 {33,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={27},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8477.                 {34,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={33},Size=UDim2.new(0,16,0,8),}},
  8478.                 {35,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={34},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8479.                 {36,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={34},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8480.                 {37,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={34},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8481.                 {38,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={25},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Green:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8482.                 {39,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Hue",Parent={1},Position=UDim2.new(1,-180,0,211),Size=UDim2.new(0,52,0,16),}},
  8483.                 {40,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={39},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8484.                 {41,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={40},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8485.                 {42,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={41},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8486.                 {43,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={42},Size=UDim2.new(0,16,0,8),}},
  8487.                 {44,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={43},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8488.                 {45,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={43},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8489.                 {46,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={43},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8490.                 {47,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={41},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8491.                 {48,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={47},Size=UDim2.new(0,16,0,8),}},
  8492.                 {49,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={48},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8493.                 {50,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={48},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8494.                 {51,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={48},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8495.                 {52,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={39},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Hue:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8496.                 {53,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Name="Preview",Parent={1},Position=UDim2.new(1,-260,0,211),Size=UDim2.new(0,35,1,-245),}},
  8497.                 {54,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Red",Parent={1},Position=UDim2.new(1,-63,0,211),Size=UDim2.new(0,52,0,16),}},
  8498.                 {55,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={54},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8499.                 {56,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={55},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8500.                 {57,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={56},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8501.                 {58,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={57},Size=UDim2.new(0,16,0,8),}},
  8502.                 {59,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={58},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8503.                 {60,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={58},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8504.                 {61,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={58},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8505.                 {62,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={56},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8506.                 {63,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={62},Size=UDim2.new(0,16,0,8),}},
  8507.                 {64,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={63},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8508.                 {65,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={63},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8509.                 {66,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={63},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8510.                 {67,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={54},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Red:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8511.                 {68,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Sat",Parent={1},Position=UDim2.new(1,-180,0,233),Size=UDim2.new(0,52,0,16),}},
  8512.                 {69,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={68},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8513.                 {70,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={69},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8514.                 {71,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={70},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8515.                 {72,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={71},Size=UDim2.new(0,16,0,8),}},
  8516.                 {73,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={72},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8517.                 {74,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={72},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8518.                 {75,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={72},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8519.                 {76,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={70},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8520.                 {77,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={76},Size=UDim2.new(0,16,0,8),}},
  8521.                 {78,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={77},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8522.                 {79,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={77},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8523.                 {80,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={77},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8524.                 {81,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={68},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Sat:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8525.                 {82,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Val",Parent={1},Position=UDim2.new(1,-180,0,255),Size=UDim2.new(0,52,0,16),}},
  8526.                 {83,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Font=3,Name="Input",Parent={82},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,50,0,16),Text="255",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8527.                 {84,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={83},Position=UDim2.new(1,-16,0,0),Size=UDim2.new(0,16,1,0),}},
  8528.                 {85,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Up",Parent={84},Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8529.                 {86,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={85},Size=UDim2.new(0,16,0,8),}},
  8530.                 {87,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={86},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,1),}},
  8531.                 {88,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={86},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8532.                 {89,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={86},Position=UDim2.new(0,6,0,5),Size=UDim2.new(0,5,0,1),}},
  8533.                 {90,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="Down",Parent={84},Position=UDim2.new(0,0,0,8),Size=UDim2.new(1,0,0,8),Text="",TextSize=14,}},
  8534.                 {91,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={90},Size=UDim2.new(0,16,0,8),}},
  8535.                 {92,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={91},Position=UDim2.new(0,8,0,5),Size=UDim2.new(0,1,0,1),}},
  8536.                 {93,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={91},Position=UDim2.new(0,7,0,4),Size=UDim2.new(0,3,0,1),}},
  8537.                 {94,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={91},Position=UDim2.new(0,6,0,3),Size=UDim2.new(0,5,0,1),}},
  8538.                 {95,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={82},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Val:",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8539.                 {96,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Font=3,Name="Cancel",Parent={1},Position=UDim2.new(1,-105,1,-28),Size=UDim2.new(0,100,0,25),Text="Cancel",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  8540.                 {97,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Font=3,Name="Ok",Parent={1},Position=UDim2.new(1,-210,1,-28),Size=UDim2.new(0,100,0,25),Text="OK",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  8541.                 {98,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Image="rbxassetid://1072518502",Name="ColorStrip",Parent={1},Position=UDim2.new(1,-30,0,5),Size=UDim2.new(0,13,0,200),}},
  8542.                 {99,"Frame",{BackgroundColor3=Color3.new(0.3137255012989,0.3137255012989,0.3137255012989),BackgroundTransparency=1,BorderSizePixel=0,Name="ArrowFrame",Parent={1},Position=UDim2.new(1,-16,0,1),Size=UDim2.new(0,5,0,208),}},
  8543.                 {100,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={99},Position=UDim2.new(0,-2,0,-4),Size=UDim2.new(0,8,0,16),}},
  8544.                 {101,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Parent={100},Position=UDim2.new(0,2,0,8),Size=UDim2.new(0,1,0,1),}},
  8545.                 {102,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Parent={100},Position=UDim2.new(0,3,0,7),Size=UDim2.new(0,1,0,3),}},
  8546.                 {103,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Parent={100},Position=UDim2.new(0,4,0,6),Size=UDim2.new(0,1,0,5),}},
  8547.                 {104,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Parent={100},Position=UDim2.new(0,5,0,5),Size=UDim2.new(0,1,0,7),}},
  8548.                 {105,"Frame",{BackgroundColor3=Color3.new(0,0,0),BorderSizePixel=0,Parent={100},Position=UDim2.new(0,6,0,4),Size=UDim2.new(0,1,0,9),}},
  8549.             })
  8550.             local window = Lib.Window.new()
  8551.             window.Resizable = false
  8552.             window.Alignable = false
  8553.             window:SetTitle("Color Picker")
  8554.             window:Resize(450,330)
  8555.             for i,v in pairs(guiContents:GetChildren()) do
  8556.                 v.Parent = window.GuiElems.Content
  8557.             end
  8558.             newMt.Window = window
  8559.             newMt.Gui = window.Gui
  8560.             local pickerGui = window.Gui.Main
  8561.             local pickerTopBar = pickerGui.TopBar
  8562.             local pickerFrame = pickerGui.Content
  8563.             local colorSpace = pickerFrame.ColorSpaceFrame.ColorSpace
  8564.             local colorStrip = pickerFrame.ColorStrip
  8565.             local previewFrame = pickerFrame.Preview
  8566.             local basicColorsFrame = pickerFrame.BasicColors
  8567.             local customColorsFrame = pickerFrame.CustomColors
  8568.             local okButton = pickerFrame.Ok
  8569.             local cancelButton = pickerFrame.Cancel
  8570.             local closeButton = pickerTopBar.Close
  8571.  
  8572.             local colorScope = colorSpace.Scope
  8573.             local colorArrow = pickerFrame.ArrowFrame.Arrow
  8574.  
  8575.             local hueInput = pickerFrame.Hue.Input
  8576.             local satInput = pickerFrame.Sat.Input
  8577.             local valInput = pickerFrame.Val.Input
  8578.  
  8579.             local redInput = pickerFrame.Red.Input
  8580.             local greenInput = pickerFrame.Green.Input
  8581.             local blueInput = pickerFrame.Blue.Input
  8582.  
  8583.             local user = cloneref(game["Run Service"].Parent:GetService("UserInputService"))
  8584.             local mouse = cloneref(game["Run Service"].Parent:GetService("Players")).LocalPlayer:GetMouse()
  8585.  
  8586.             local hue,sat,val = 0,0,1
  8587.             local red,green,blue = 1,1,1
  8588.             local chosenColor = Color3.new(0,0,0)
  8589.  
  8590.             local basicColors = {Color3.new(0,0,0),Color3.new(0.66666668653488,0,0),Color3.new(0,0.33333334326744,0),Color3.new(0.66666668653488,0.33333334326744,0),Color3.new(0,0.66666668653488,0),Color3.new(0.66666668653488,0.66666668653488,0),Color3.new(0,1,0),Color3.new(0.66666668653488,1,0),Color3.new(0,0,0.49803924560547),Color3.new(0.66666668653488,0,0.49803924560547),Color3.new(0,0.33333334326744,0.49803924560547),Color3.new(0.66666668653488,0.33333334326744,0.49803924560547),Color3.new(0,0.66666668653488,0.49803924560547),Color3.new(0.66666668653488,0.66666668653488,0.49803924560547),Color3.new(0,1,0.49803924560547),Color3.new(0.66666668653488,1,0.49803924560547),Color3.new(0,0,1),Color3.new(0.66666668653488,0,1),Color3.new(0,0.33333334326744,1),Color3.new(0.66666668653488,0.33333334326744,1),Color3.new(0,0.66666668653488,1),Color3.new(0.66666668653488,0.66666668653488,1),Color3.new(0,1,1),Color3.new(0.66666668653488,1,1),Color3.new(0.33333334326744,0,0),Color3.new(1,0,0),Color3.new(0.33333334326744,0.33333334326744,0),Color3.new(1,0.33333334326744,0),Color3.new(0.33333334326744,0.66666668653488,0),Color3.new(1,0.66666668653488,0),Color3.new(0.33333334326744,1,0),Color3.new(1,1,0),Color3.new(0.33333334326744,0,0.49803924560547),Color3.new(1,0,0.49803924560547),Color3.new(0.33333334326744,0.33333334326744,0.49803924560547),Color3.new(1,0.33333334326744,0.49803924560547),Color3.new(0.33333334326744,0.66666668653488,0.49803924560547),Color3.new(1,0.66666668653488,0.49803924560547),Color3.new(0.33333334326744,1,0.49803924560547),Color3.new(1,1,0.49803924560547),Color3.new(0.33333334326744,0,1),Color3.new(1,0,1),Color3.new(0.33333334326744,0.33333334326744,1),Color3.new(1,0.33333334326744,1),Color3.new(0.33333334326744,0.66666668653488,1),Color3.new(1,0.66666668653488,1),Color3.new(0.33333334326744,1,1),Color3.new(1,1,1)}
  8591.             local customColors = {}
  8592.  
  8593.             local function updateColor(noupdate)
  8594.                 local relativeX,relativeY,relativeStripY = 219 - hue*219, 199 - sat*199, 199 - val*199
  8595.                 local hsvColor = Color3.fromHSV(hue,sat,val)
  8596.  
  8597.                 if noupdate == 2 or not noupdate then
  8598.                     hueInput.Text = tostring(math.ceil(359*hue))
  8599.                     satInput.Text = tostring(math.ceil(255*sat))
  8600.                     valInput.Text = tostring(math.floor(255*val))
  8601.                 end
  8602.                 if noupdate == 1 or not noupdate then
  8603.                     redInput.Text = tostring(math.floor(255*red))
  8604.                     greenInput.Text = tostring(math.floor(255*green))
  8605.                     blueInput.Text = tostring(math.floor(255*blue))
  8606.                 end
  8607.  
  8608.                 chosenColor = Color3.new(red,green,blue)
  8609.  
  8610.                 colorScope.Position = UDim2.new(0,relativeX-9,0,relativeY-9)
  8611.                 colorStrip.ImageColor3 = Color3.fromHSV(hue,sat,1)
  8612.                 colorArrow.Position = UDim2.new(0,-2,0,relativeStripY-4)
  8613.                 previewFrame.BackgroundColor3 = chosenColor
  8614.  
  8615.                 newMt.Color = chosenColor
  8616.                 newMt.OnPreview:Fire(chosenColor)
  8617.             end
  8618.  
  8619.             local function colorSpaceInput()
  8620.                 local relativeX = mouse.X - colorSpace.AbsolutePosition.X
  8621.                 local relativeY = mouse.Y - colorSpace.AbsolutePosition.Y
  8622.  
  8623.                 if relativeX < 0 then relativeX = 0 elseif relativeX > 219 then relativeX = 219 end
  8624.                 if relativeY < 0 then relativeY = 0 elseif relativeY > 199 then relativeY = 199 end
  8625.  
  8626.                 hue = (219 - relativeX)/219
  8627.                 sat = (199 - relativeY)/199
  8628.  
  8629.                 local hsvColor = Color3.fromHSV(hue,sat,val)
  8630.                 red,green,blue = hsvColor.r,hsvColor.g,hsvColor.b
  8631.  
  8632.                 updateColor()
  8633.             end
  8634.  
  8635.             local function colorStripInput()
  8636.                 local relativeY = mouse.Y - colorStrip.AbsolutePosition.Y
  8637.  
  8638.                 if relativeY < 0 then relativeY = 0 elseif relativeY > 199 then relativeY = 199 end
  8639.  
  8640.                 val = (199 - relativeY)/199
  8641.  
  8642.                 local hsvColor = Color3.fromHSV(hue,sat,val)
  8643.                 red,green,blue = hsvColor.r,hsvColor.g,hsvColor.b
  8644.  
  8645.                 updateColor()
  8646.             end
  8647.  
  8648.             local function hookButtons(frame,func)
  8649.                 frame.ArrowFrame.Up.InputBegan:Connect(function(input)
  8650.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  8651.                         frame.ArrowFrame.Up.BackgroundTransparency = 0.5
  8652.                     elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  8653.                         local releaseEvent,runEvent
  8654.  
  8655.                         local startTime = tick()
  8656.                         local pressing = true
  8657.                         local startNum = tonumber(frame.Text)
  8658.  
  8659.                         if not startNum then return end
  8660.  
  8661.                         releaseEvent = user.InputEnded:Connect(function(input)
  8662.                             if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  8663.                             releaseEvent:Disconnect()
  8664.                             pressing = false
  8665.                         end)
  8666.  
  8667.                         startNum = startNum + 1
  8668.                         func(startNum)
  8669.                         while pressing do
  8670.                             if tick()-startTime > 0.3 then
  8671.                                 startNum = startNum + 1
  8672.                                 func(startNum)
  8673.                             end
  8674.                             wait(0.1)
  8675.                         end
  8676.                     end
  8677.                 end)
  8678.  
  8679.                 frame.ArrowFrame.Up.InputEnded:Connect(function(input)
  8680.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  8681.                         frame.ArrowFrame.Up.BackgroundTransparency = 1
  8682.                     end
  8683.                 end)
  8684.  
  8685.                 frame.ArrowFrame.Down.InputBegan:Connect(function(input)
  8686.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  8687.                         frame.ArrowFrame.Down.BackgroundTransparency = 0.5
  8688.                     elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  8689.                         local releaseEvent,runEvent
  8690.  
  8691.                         local startTime = tick()
  8692.                         local pressing = true
  8693.                         local startNum = tonumber(frame.Text)
  8694.  
  8695.                         if not startNum then return end
  8696.  
  8697.                         releaseEvent = user.InputEnded:Connect(function(input)
  8698.                             if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  8699.                             releaseEvent:Disconnect()
  8700.                             pressing = false
  8701.                         end)
  8702.  
  8703.                         startNum = startNum - 1
  8704.                         func(startNum)
  8705.                         while pressing do
  8706.                             if tick()-startTime > 0.3 then
  8707.                                 startNum = startNum - 1
  8708.                                 func(startNum)
  8709.                             end
  8710.                             wait(0.1)
  8711.                         end
  8712.                     end
  8713.                 end)
  8714.  
  8715.                 frame.ArrowFrame.Down.InputEnded:Connect(function(input)
  8716.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  8717.                         frame.ArrowFrame.Down.BackgroundTransparency = 1
  8718.                     end
  8719.                 end)
  8720.             end
  8721.  
  8722.             colorSpace.InputBegan:Connect(function(input)
  8723.                 if input.UserInputType == Enum.UserInputType.MouseButton1 then
  8724.                     local releaseEvent,mouseEvent
  8725.  
  8726.                     releaseEvent = user.InputEnded:Connect(function(input)
  8727.                         if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  8728.                         releaseEvent:Disconnect()
  8729.                         mouseEvent:Disconnect()
  8730.                     end)
  8731.  
  8732.                     mouseEvent = user.InputChanged:Connect(function(input)
  8733.                         if input.UserInputType == Enum.UserInputType.MouseMovement then
  8734.                             colorSpaceInput()
  8735.                         end
  8736.                     end)
  8737.  
  8738.                     colorSpaceInput()
  8739.                 end
  8740.             end)
  8741.  
  8742.             colorStrip.InputBegan:Connect(function(input)
  8743.                 if input.UserInputType == Enum.UserInputType.MouseButton1 then
  8744.                     local releaseEvent,mouseEvent
  8745.  
  8746.                     releaseEvent = user.InputEnded:Connect(function(input)
  8747.                         if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  8748.                         releaseEvent:Disconnect()
  8749.                         mouseEvent:Disconnect()
  8750.                     end)
  8751.  
  8752.                     mouseEvent = user.InputChanged:Connect(function(input)
  8753.                         if input.UserInputType == Enum.UserInputType.MouseMovement then
  8754.                             colorStripInput()
  8755.                         end
  8756.                     end)
  8757.  
  8758.                     colorStripInput()
  8759.                 end
  8760.             end)
  8761.  
  8762.             local function updateHue(str)
  8763.                 local num = tonumber(str)
  8764.                 if num then
  8765.                     hue = math.clamp(math.floor(num),0,359)/359
  8766.                     local hsvColor = Color3.fromHSV(hue,sat,val)
  8767.                     red,green,blue = hsvColor.r,hsvColor.g,hsvColor.b
  8768.                     hueInput.Text = tostring(hue*359)
  8769.                     updateColor(1)
  8770.                 end
  8771.             end
  8772.             hueInput.FocusLost:Connect(function() updateHue(hueInput.Text) end) hookButtons(hueInput,updateHue)
  8773.  
  8774.             local function updateSat(str)
  8775.                 local num = tonumber(str)
  8776.                 if num then
  8777.                     sat = math.clamp(math.floor(num),0,255)/255
  8778.                     local hsvColor = Color3.fromHSV(hue,sat,val)
  8779.                     red,green,blue = hsvColor.r,hsvColor.g,hsvColor.b
  8780.                     satInput.Text = tostring(sat*255)
  8781.                     updateColor(1)
  8782.                 end
  8783.             end
  8784.             satInput.FocusLost:Connect(function() updateSat(satInput.Text) end) hookButtons(satInput,updateSat)
  8785.  
  8786.             local function updateVal(str)
  8787.                 local num = tonumber(str)
  8788.                 if num then
  8789.                     val = math.clamp(math.floor(num),0,255)/255
  8790.                     local hsvColor = Color3.fromHSV(hue,sat,val)
  8791.                     red,green,blue = hsvColor.r,hsvColor.g,hsvColor.b
  8792.                     valInput.Text = tostring(val*255)
  8793.                     updateColor(1)
  8794.                 end
  8795.             end
  8796.             valInput.FocusLost:Connect(function() updateVal(valInput.Text) end) hookButtons(valInput,updateVal)
  8797.  
  8798.             local function updateRed(str)
  8799.                 local num = tonumber(str)
  8800.                 if num then
  8801.                     red = math.clamp(math.floor(num),0,255)/255
  8802.                     local newColor = Color3.new(red,green,blue)
  8803.                     hue,sat,val = Color3.toHSV(newColor)
  8804.                     redInput.Text = tostring(red*255)
  8805.                     updateColor(2)
  8806.                 end
  8807.             end
  8808.             redInput.FocusLost:Connect(function() updateRed(redInput.Text) end) hookButtons(redInput,updateRed)
  8809.  
  8810.             local function updateGreen(str)
  8811.                 local num = tonumber(str)
  8812.                 if num then
  8813.                     green = math.clamp(math.floor(num),0,255)/255
  8814.                     local newColor = Color3.new(red,green,blue)
  8815.                     hue,sat,val = Color3.toHSV(newColor)
  8816.                     greenInput.Text = tostring(green*255)
  8817.                     updateColor(2)
  8818.                 end
  8819.             end
  8820.             greenInput.FocusLost:Connect(function() updateGreen(greenInput.Text) end) hookButtons(greenInput,updateGreen)
  8821.  
  8822.             local function updateBlue(str)
  8823.                 local num = tonumber(str)
  8824.                 if num then
  8825.                     blue = math.clamp(math.floor(num),0,255)/255
  8826.                     local newColor = Color3.new(red,green,blue)
  8827.                     hue,sat,val = Color3.toHSV(newColor)
  8828.                     blueInput.Text = tostring(blue*255)
  8829.                     updateColor(2)
  8830.                 end
  8831.             end
  8832.             blueInput.FocusLost:Connect(function() updateBlue(blueInput.Text) end) hookButtons(blueInput,updateBlue)
  8833.  
  8834.             local colorChoice = Instance.new("TextButton")
  8835.             colorChoice.Name = "Choice"
  8836.             colorChoice.Size = UDim2.new(0,25,0,18)
  8837.             colorChoice.BorderColor3 = Color3.fromRGB(55,55,55)
  8838.             colorChoice.Text = ""
  8839.             colorChoice.AutoButtonColor = false
  8840.  
  8841.             local row = 0
  8842.             local column = 0
  8843.             for i,v in pairs(basicColors) do
  8844.                 local newColor = colorChoice:Clone()
  8845.                 newColor.BackgroundColor3 = v
  8846.                 newColor.Position = UDim2.new(0,1 + 30*column,0,21 + 23*row)
  8847.  
  8848.                 newColor.MouseButton1Click:Connect(function()
  8849.                     red,green,blue = v.r,v.g,v.b
  8850.                     local newColor = Color3.new(red,green,blue)
  8851.                     hue,sat,val = Color3.toHSV(newColor)
  8852.                     updateColor()
  8853.                 end)   
  8854.  
  8855.                 newColor.Parent = basicColorsFrame
  8856.                 column = column + 1
  8857.                 if column == 6 then row = row + 1 column = 0 end
  8858.             end
  8859.  
  8860.             row = 0
  8861.             column = 0
  8862.             for i = 1,12 do
  8863.                 local color = customColors[i] or Color3.new(0,0,0)
  8864.                 local newColor = colorChoice:Clone()
  8865.                 newColor.BackgroundColor3 = color
  8866.                 newColor.Position = UDim2.new(0,1 + 30*column,0,20 + 23*row)
  8867.  
  8868.                 newColor.MouseButton1Click:Connect(function()
  8869.                     local curColor = customColors[i] or Color3.new(0,0,0)
  8870.                     red,green,blue = curColor.r,curColor.g,curColor.b
  8871.                     hue,sat,val = Color3.toHSV(curColor)
  8872.                     updateColor()
  8873.                 end)
  8874.  
  8875.                 newColor.MouseButton2Click:Connect(function()
  8876.                     customColors[i] = chosenColor
  8877.                     newColor.BackgroundColor3 = chosenColor
  8878.                 end)
  8879.  
  8880.                 newColor.Parent = customColorsFrame
  8881.                 column = column + 1
  8882.                 if column == 6 then row = row + 1 column = 0 end
  8883.             end
  8884.  
  8885.             okButton.MouseButton1Click:Connect(function() newMt.OnSelect:Fire(chosenColor) window:Close() end)
  8886.             okButton.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then okButton.BackgroundTransparency = 0.4 end end)
  8887.             okButton.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then okButton.BackgroundTransparency = 0 end end)
  8888.  
  8889.             cancelButton.MouseButton1Click:Connect(function() newMt.OnCancel:Fire() window:Close() end)
  8890.             cancelButton.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then cancelButton.BackgroundTransparency = 0.4 end end)
  8891.             cancelButton.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then cancelButton.BackgroundTransparency = 0 end end)
  8892.  
  8893.             updateColor()
  8894.  
  8895.             newMt.SetColor = function(self,color)
  8896.                 red,green,blue = color.r,color.g,color.b
  8897.                 hue,sat,val = Color3.toHSV(color)
  8898.                 updateColor()
  8899.             end
  8900.  
  8901.             newMt.Show = function(self)
  8902.                 self.Window:Show()
  8903.             end
  8904.  
  8905.             return newMt
  8906.         end
  8907.  
  8908.         return {new = new}
  8909.     end)()
  8910.  
  8911.     Lib.NumberSequenceEditor = (function()
  8912.         local function new() -- TODO: Convert to newer class model
  8913.             local newMt = setmetatable({},{})
  8914.             newMt.OnSelect = Lib.Signal.new()
  8915.             newMt.OnCancel = Lib.Signal.new()
  8916.             newMt.OnPreview = Lib.Signal.new()
  8917.  
  8918.             local guiContents = create({
  8919.                 {1,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,ClipsDescendants=true,Name="Content",Position=UDim2.new(0,0,0,20),Size=UDim2.new(1,0,1,-20),}},
  8920.                 {2,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Time",Parent={1},Position=UDim2.new(0,40,0,210),Size=UDim2.new(0,60,0,20),}},
  8921.                 {3,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),ClipsDescendants=true,Font=3,Name="Input",Parent={2},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,58,0,20),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8922.                 {4,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={2},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Time",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8923.                 {5,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Font=3,Name="Close",Parent={1},Position=UDim2.new(1,-90,0,210),Size=UDim2.new(0,80,0,20),Text="Close",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  8924.                 {6,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Font=3,Name="Reset",Parent={1},Position=UDim2.new(1,-180,0,210),Size=UDim2.new(0,80,0,20),Text="Reset",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  8925.                 {7,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Font=3,Name="Delete",Parent={1},Position=UDim2.new(0,380,0,210),Size=UDim2.new(0,80,0,20),Text="Delete",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  8926.                 {8,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Name="NumberLineOutlines",Parent={1},Position=UDim2.new(0,10,0,20),Size=UDim2.new(1,-20,0,170),}},
  8927.                 {9,"Frame",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),Name="NumberLine",Parent={1},Position=UDim2.new(0,10,0,20),Size=UDim2.new(1,-20,0,170),}},
  8928.                 {10,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Value",Parent={1},Position=UDim2.new(0,170,0,210),Size=UDim2.new(0,60,0,20),}},
  8929.                 {11,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={10},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Value",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8930.                 {12,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),ClipsDescendants=true,Font=3,Name="Input",Parent={10},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,58,0,20),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8931.                 {13,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Envelope",Parent={1},Position=UDim2.new(0,300,0,210),Size=UDim2.new(0,60,0,20),}},
  8932.                 {14,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),ClipsDescendants=true,Font=3,Name="Input",Parent={13},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,58,0,20),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  8933.                 {15,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={13},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Envelope",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  8934.             })
  8935.             local window = Lib.Window.new()
  8936.             window.Resizable = false
  8937.             window:Resize(680,265)
  8938.             window:SetTitle("NumberSequence Editor")
  8939.             newMt.Window = window
  8940.             newMt.Gui = window.Gui
  8941.             for i,v in pairs(guiContents:GetChildren()) do
  8942.                 v.Parent = window.GuiElems.Content
  8943.             end
  8944.             local gui = window.Gui
  8945.             local pickerGui = gui.Main
  8946.             local pickerTopBar = pickerGui.TopBar
  8947.             local pickerFrame = pickerGui.Content
  8948.             local numberLine = pickerFrame.NumberLine
  8949.             local numberLineOutlines = pickerFrame.NumberLineOutlines
  8950.             local timeBox = pickerFrame.Time.Input
  8951.             local valueBox = pickerFrame.Value.Input
  8952.             local envelopeBox = pickerFrame.Envelope.Input
  8953.             local deleteButton = pickerFrame.Delete
  8954.             local resetButton = pickerFrame.Reset
  8955.             local closeButton = pickerFrame.Close
  8956.             local topClose = pickerTopBar.Close
  8957.  
  8958.             local points = {{1,0,3},{8,0.05,1},{5,0.6,2},{4,0.7,4},{6,1,4}}
  8959.             local lines = {}
  8960.             local eLines = {}
  8961.             local beginPoint = points[1]
  8962.             local endPoint = points[#points]
  8963.             local currentlySelected = nil
  8964.             local currentPoint = nil
  8965.             local resetSequence = nil
  8966.  
  8967.             local user = cloneref(game["Run Service"].Parent:GetService("UserInputService"))
  8968.             local mouse = cloneref(game["Run Service"].Parent:GetService("Players")).LocalPlayer:GetMouse()
  8969.  
  8970.             for i = 2,10 do
  8971.                 local newLine = Instance.new("Frame")
  8972.                 newLine.BackgroundTransparency = 0.5
  8973.                 newLine.BackgroundColor3 = Color3.new(96/255,96/255,96/255)
  8974.                 newLine.BorderSizePixel = 0
  8975.                 newLine.Size = UDim2.new(0,1,1,0)
  8976.                 newLine.Position = UDim2.new((i-1)/(11-1),0,0,0)
  8977.                 newLine.Parent = numberLineOutlines
  8978.             end
  8979.  
  8980.             for i = 2,4 do
  8981.                 local newLine = Instance.new("Frame")
  8982.                 newLine.BackgroundTransparency = 0.5
  8983.                 newLine.BackgroundColor3 = Color3.new(96/255,96/255,96/255)
  8984.                 newLine.BorderSizePixel = 0
  8985.                 newLine.Size = UDim2.new(1,0,0,1)
  8986.                 newLine.Position = UDim2.new(0,0,(i-1)/(5-1),0)
  8987.                 newLine.Parent = numberLineOutlines
  8988.             end
  8989.  
  8990.             local lineTemp = Instance.new("Frame")
  8991.             lineTemp.BackgroundColor3 = Color3.new(0,0,0)
  8992.             lineTemp.BorderSizePixel = 0
  8993.             lineTemp.Size = UDim2.new(0,1,0,1)
  8994.  
  8995.             local sequenceLine = Instance.new("Frame")
  8996.             sequenceLine.BackgroundColor3 = Color3.new(0,0,0)
  8997.             sequenceLine.BorderSizePixel = 0
  8998.             sequenceLine.Size = UDim2.new(0,1,0,0)
  8999.  
  9000.             for i = 1,numberLine.AbsoluteSize.X do
  9001.                 local line = sequenceLine:Clone()
  9002.                 eLines[i] = line
  9003.                 line.Name = "E"..tostring(i)
  9004.                 line.BackgroundTransparency = 0.5
  9005.                 line.BackgroundColor3 = Color3.new(199/255,44/255,28/255)
  9006.                 line.Position = UDim2.new(0,i-1,0,0)
  9007.                 line.Parent = numberLine
  9008.             end
  9009.  
  9010.             for i = 1,numberLine.AbsoluteSize.X do
  9011.                 local line = sequenceLine:Clone()
  9012.                 lines[i] = line
  9013.                 line.Name = tostring(i)
  9014.                 line.Position = UDim2.new(0,i-1,0,0)
  9015.                 line.Parent = numberLine
  9016.             end
  9017.  
  9018.             local envelopeDrag = Instance.new("Frame")
  9019.             envelopeDrag.BackgroundTransparency = 1
  9020.             envelopeDrag.BackgroundColor3 = Color3.new(0,0,0)
  9021.             envelopeDrag.BorderSizePixel = 0
  9022.             envelopeDrag.Size = UDim2.new(0,7,0,20)
  9023.             envelopeDrag.Visible = false
  9024.             envelopeDrag.ZIndex = 2
  9025.             local envelopeDragLine = Instance.new("Frame",envelopeDrag)
  9026.             envelopeDragLine.Name = "Line"
  9027.             envelopeDragLine.BackgroundColor3 = Color3.new(0,0,0)
  9028.             envelopeDragLine.BorderSizePixel = 0
  9029.             envelopeDragLine.Position = UDim2.new(0,3,0,0)
  9030.             envelopeDragLine.Size = UDim2.new(0,1,0,20)
  9031.             envelopeDragLine.ZIndex = 2
  9032.  
  9033.             local envelopeDragTop,envelopeDragBottom = envelopeDrag:Clone(),envelopeDrag:Clone()
  9034.             envelopeDragTop.Parent = numberLine
  9035.             envelopeDragBottom.Parent = numberLine
  9036.  
  9037.             local function buildSequence()
  9038.                 local newPoints = {}
  9039.                 for i,v in pairs(points) do
  9040.                     table.insert(newPoints,NumberSequenceKeypoint.new(v[2],v[1],v[3]))
  9041.                 end
  9042.                 newMt.Sequence = NumberSequence.new(newPoints)
  9043.                 newMt.OnSelect:Fire(newMt.Sequence)
  9044.             end
  9045.  
  9046.             local function round(num,places)
  9047.                 local multi = 10^places
  9048.                 return math.floor(num*multi + 0.5)/multi
  9049.             end
  9050.  
  9051.             local function updateInputs(point)
  9052.                 if point then
  9053.                     currentPoint = point
  9054.                     local rawT,rawV,rawE = point[2],point[1],point[3]
  9055.                     timeBox.Text = round(rawT,(rawT < 0.01 and 5) or (rawT < 0.1 and 4) or 3)
  9056.                     valueBox.Text = round(rawV,(rawV < 0.01 and 5) or (rawV < 0.1 and 4) or (rawV < 1 and 3) or 2)
  9057.                     envelopeBox.Text = round(rawE,(rawE < 0.01 and 5) or (rawE < 0.1 and 4) or (rawV < 1 and 3) or 2)
  9058.  
  9059.                     local envelopeDistance = numberLine.AbsoluteSize.Y*(point[3]/10)
  9060.                     envelopeDragTop.Position = UDim2.new(0,point[4].Position.X.Offset-1,0,point[4].Position.Y.Offset-envelopeDistance-17)
  9061.                     envelopeDragTop.Visible = true
  9062.                     envelopeDragBottom.Position = UDim2.new(0,point[4].Position.X.Offset-1,0,point[4].Position.Y.Offset+envelopeDistance+2)
  9063.                     envelopeDragBottom.Visible = true
  9064.                 end
  9065.             end
  9066.  
  9067.             envelopeDragTop.InputBegan:Connect(function(input)
  9068.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 or not currentPoint or Lib.CheckMouseInGui(currentPoint[4].Select) then return end
  9069.                 local mouseEvent,releaseEvent
  9070.                 local maxSize = numberLine.AbsoluteSize.Y
  9071.  
  9072.                 local mouseDelta = math.abs(envelopeDragTop.AbsolutePosition.Y - mouse.Y)
  9073.  
  9074.                 envelopeDragTop.Line.Position = UDim2.new(0,2,0,0)
  9075.                 envelopeDragTop.Line.Size = UDim2.new(0,3,0,20)
  9076.  
  9077.                 releaseEvent = user.InputEnded:Connect(function(input)
  9078.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  9079.                     mouseEvent:Disconnect()
  9080.                     releaseEvent:Disconnect()
  9081.                     envelopeDragTop.Line.Position = UDim2.new(0,3,0,0)
  9082.                     envelopeDragTop.Line.Size = UDim2.new(0,1,0,20)
  9083.                 end)
  9084.  
  9085.                 mouseEvent = user.InputChanged:Connect(function(input)
  9086.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  9087.                         local topDiff = (currentPoint[4].AbsolutePosition.Y+2)-(mouse.Y-mouseDelta)-19
  9088.                         local newEnvelope = 10*(math.max(topDiff,0)/maxSize)
  9089.                         local maxEnvelope = math.min(currentPoint[1],10-currentPoint[1])
  9090.                         currentPoint[3] = math.min(newEnvelope,maxEnvelope)
  9091.                         newMt:Redraw()
  9092.                         buildSequence()
  9093.                         updateInputs(currentPoint)
  9094.                     end
  9095.                 end)
  9096.             end)
  9097.  
  9098.             envelopeDragBottom.InputBegan:Connect(function(input)
  9099.                 if input.UserInputType ~= Enum.UserInputType.MouseButton1 or not currentPoint or Lib.CheckMouseInGui(currentPoint[4].Select) then return end
  9100.                 local mouseEvent,releaseEvent
  9101.                 local maxSize = numberLine.AbsoluteSize.Y
  9102.  
  9103.                 local mouseDelta = math.abs(envelopeDragBottom.AbsolutePosition.Y - mouse.Y)
  9104.  
  9105.                 envelopeDragBottom.Line.Position = UDim2.new(0,2,0,0)
  9106.                 envelopeDragBottom.Line.Size = UDim2.new(0,3,0,20)
  9107.  
  9108.                 releaseEvent = user.InputEnded:Connect(function(input)
  9109.                     if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  9110.                     mouseEvent:Disconnect()
  9111.                     releaseEvent:Disconnect()
  9112.                     envelopeDragBottom.Line.Position = UDim2.new(0,3,0,0)
  9113.                     envelopeDragBottom.Line.Size = UDim2.new(0,1,0,20)
  9114.                 end)
  9115.  
  9116.                 mouseEvent = user.InputChanged:Connect(function(input)
  9117.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  9118.                         local bottomDiff = (mouse.Y+(20-mouseDelta))-(currentPoint[4].AbsolutePosition.Y+2)-19
  9119.                         local newEnvelope = 10*(math.max(bottomDiff,0)/maxSize)
  9120.                         local maxEnvelope = math.min(currentPoint[1],10-currentPoint[1])
  9121.                         currentPoint[3] = math.min(newEnvelope,maxEnvelope)
  9122.                         newMt:Redraw()
  9123.                         buildSequence()
  9124.                         updateInputs(currentPoint)
  9125.                     end
  9126.                 end)
  9127.             end)
  9128.  
  9129.             local function placePoint(point)
  9130.                 local newPoint = Instance.new("Frame")
  9131.                 newPoint.Name = "Point"
  9132.                 newPoint.BorderSizePixel = 0
  9133.                 newPoint.Size = UDim2.new(0,5,0,5)
  9134.                 newPoint.Position = UDim2.new(0,math.floor((numberLine.AbsoluteSize.X-1) * point[2])-2,0,numberLine.AbsoluteSize.Y*(10-point[1])/10-2)
  9135.                 newPoint.BackgroundColor3 = Color3.new(0,0,0)
  9136.  
  9137.                 local newSelect = Instance.new("Frame")
  9138.                 newSelect.Name = "Select"
  9139.                 newSelect.BackgroundTransparency = 1
  9140.                 newSelect.BackgroundColor3 = Color3.new(199/255,44/255,28/255)
  9141.                 newSelect.Position = UDim2.new(0,-2,0,-2)
  9142.                 newSelect.Size = UDim2.new(0,9,0,9)
  9143.                 newSelect.Parent = newPoint
  9144.  
  9145.                 newPoint.Parent = numberLine
  9146.  
  9147.                 newSelect.InputBegan:Connect(function(input)
  9148.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  9149.                         for i,v in pairs(points) do v[4].Select.BackgroundTransparency = 1 end
  9150.                         newSelect.BackgroundTransparency = 0
  9151.                         updateInputs(point)
  9152.                     end
  9153.                     if input.UserInputType == Enum.UserInputType.MouseButton1 and not currentlySelected then
  9154.                         currentPoint = point
  9155.                         local mouseEvent,releaseEvent
  9156.                         currentlySelected = true
  9157.                         newSelect.BackgroundColor3 = Color3.new(249/255,191/255,59/255)
  9158.  
  9159.                         local oldEnvelope = point[3]
  9160.  
  9161.                         releaseEvent = user.InputEnded:Connect(function(input)
  9162.                             if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  9163.                             mouseEvent:Disconnect()
  9164.                             releaseEvent:Disconnect()
  9165.                             currentlySelected = nil
  9166.                             newSelect.BackgroundColor3 = Color3.new(199/255,44/255,28/255)
  9167.                         end)
  9168.  
  9169.                         mouseEvent = user.InputChanged:Connect(function(input)
  9170.                             if input.UserInputType == Enum.UserInputType.MouseMovement then
  9171.                                 local maxX = numberLine.AbsoluteSize.X-1
  9172.                                 local relativeX = mouse.X - numberLine.AbsolutePosition.X
  9173.                                 if relativeX < 0 then relativeX = 0 end
  9174.                                 if relativeX > maxX then relativeX = maxX end
  9175.                                 local maxY = numberLine.AbsoluteSize.Y-1
  9176.                                 local relativeY = mouse.Y - numberLine.AbsolutePosition.Y
  9177.                                 if relativeY < 0 then relativeY = 0 end
  9178.                                 if relativeY > maxY then relativeY = maxY end
  9179.                                 if point ~= beginPoint and point ~= endPoint then
  9180.                                     point[2] = relativeX/maxX
  9181.                                 end
  9182.                                 point[1] = 10-(relativeY/maxY)*10
  9183.                                 local maxEnvelope = math.min(point[1],10-point[1])
  9184.                                 point[3] = math.min(oldEnvelope,maxEnvelope)
  9185.                                 newMt:Redraw()
  9186.                                 updateInputs(point)
  9187.                                 for i,v in pairs(points) do v[4].Select.BackgroundTransparency = 1 end
  9188.                                 newSelect.BackgroundTransparency = 0
  9189.                                 buildSequence()
  9190.                             end
  9191.                         end)
  9192.                     end
  9193.                 end)
  9194.  
  9195.                 return newPoint
  9196.             end
  9197.  
  9198.             local function placePoints()
  9199.                 for i,v in pairs(points) do
  9200.                     v[4] = placePoint(v)
  9201.                 end
  9202.             end
  9203.  
  9204.             local function redraw(self)
  9205.                 local numberLineSize = numberLine.AbsoluteSize
  9206.                 table.sort(points,function(a,b) return a[2] < b[2] end)
  9207.                 for i,v in pairs(points) do
  9208.                     v[4].Position = UDim2.new(0,math.floor((numberLineSize.X-1) * v[2])-2,0,(numberLineSize.Y-1)*(10-v[1])/10-2)
  9209.                 end
  9210.                 lines[1].Size = UDim2.new(0,1,0,0)
  9211.                 for i = 1,#points-1 do
  9212.                     local fromPoint = points[i]
  9213.                     local toPoint = points[i+1]
  9214.                     local deltaY = toPoint[4].Position.Y.Offset-fromPoint[4].Position.Y.Offset
  9215.                     local deltaX = toPoint[4].Position.X.Offset-fromPoint[4].Position.X.Offset
  9216.                     local slope = deltaY/deltaX
  9217.  
  9218.                     local fromEnvelope = fromPoint[3]
  9219.                     local nextEnvelope = toPoint[3]
  9220.  
  9221.                     local currentRise = math.abs(slope)
  9222.                     local totalRise = 0
  9223.                     local maxRise = math.abs(toPoint[4].Position.Y.Offset-fromPoint[4].Position.Y.Offset)
  9224.  
  9225.                     for lineCount = math.min(fromPoint[4].Position.X.Offset+1,toPoint[4].Position.X.Offset),toPoint[4].Position.X.Offset do
  9226.                         if deltaX == 0 and deltaY == 0 then return end
  9227.                         local riseNow = math.floor(currentRise)
  9228.                         local line = lines[lineCount+3]
  9229.                         if line then
  9230.                             if totalRise+riseNow > maxRise then riseNow = maxRise-totalRise end
  9231.                             if math.sign(slope) == -1 then
  9232.                                 line.Position = UDim2.new(0,lineCount+2,0,fromPoint[4].Position.Y.Offset + -(totalRise+riseNow)+2)
  9233.                             else
  9234.                                 line.Position = UDim2.new(0,lineCount+2,0,fromPoint[4].Position.Y.Offset + totalRise+2)
  9235.                             end
  9236.                             line.Size = UDim2.new(0,1,0,math.max(riseNow,1))
  9237.                         end
  9238.                         totalRise = totalRise + riseNow
  9239.                         currentRise = currentRise - riseNow + math.abs(slope)
  9240.  
  9241.                         local envPercent = (lineCount-fromPoint[4].Position.X.Offset)/(toPoint[4].Position.X.Offset-fromPoint[4].Position.X.Offset)
  9242.                         local envLerp = fromEnvelope+(nextEnvelope-fromEnvelope)*envPercent
  9243.                         local relativeSize = (envLerp/10)*numberLineSize.Y                     
  9244.  
  9245.                         local line = eLines[lineCount + 3]
  9246.                         if line then
  9247.                             line.Position = UDim2.new(0,lineCount+2,0,lines[lineCount+3].Position.Y.Offset-math.floor(relativeSize))
  9248.                             line.Size = UDim2.new(0,1,0,math.floor(relativeSize*2))
  9249.                         end
  9250.                     end
  9251.                 end
  9252.             end
  9253.             newMt.Redraw = redraw
  9254.  
  9255.             local function loadSequence(self,seq)
  9256.                 resetSequence = seq
  9257.                 for i,v in pairs(points) do if v[4] then v[4]:Destroy() end end
  9258.                 points = {}
  9259.                 for i,v in pairs(seq.Keypoints) do
  9260.                     local maxEnvelope = math.min(v.Value,10-v.Value)
  9261.                     local newPoint = {v.Value,v.Time,math.min(v.Envelope,maxEnvelope)}
  9262.                     newPoint[4] = placePoint(newPoint)
  9263.                     table.insert(points,newPoint)
  9264.                 end
  9265.                 beginPoint = points[1]
  9266.                 endPoint = points[#points]
  9267.                 currentlySelected = nil
  9268.                 redraw()
  9269.                 envelopeDragTop.Visible = false
  9270.                 envelopeDragBottom.Visible = false
  9271.             end
  9272.             newMt.SetSequence = loadSequence
  9273.  
  9274.             timeBox.FocusLost:Connect(function()
  9275.                 local point = currentPoint
  9276.                 local num = tonumber(timeBox.Text)
  9277.                 if point and num and point ~= beginPoint and point ~= endPoint then
  9278.                     num = math.clamp(num,0,1)
  9279.                     point[2] = num
  9280.                     redraw()
  9281.                     buildSequence()
  9282.                     updateInputs(point)
  9283.                 end
  9284.             end)
  9285.  
  9286.             valueBox.FocusLost:Connect(function()
  9287.                 local point = currentPoint
  9288.                 local num = tonumber(valueBox.Text)
  9289.                 if point and num then
  9290.                     local oldEnvelope = point[3]
  9291.                     num = math.clamp(num,0,10)
  9292.                     point[1] = num
  9293.                     local maxEnvelope = math.min(point[1],10-point[1])
  9294.                     point[3] = math.min(oldEnvelope,maxEnvelope)
  9295.                     redraw()
  9296.                     buildSequence()
  9297.                     updateInputs(point)
  9298.                 end
  9299.             end)
  9300.  
  9301.             envelopeBox.FocusLost:Connect(function()
  9302.                 local point = currentPoint
  9303.                 local num = tonumber(envelopeBox.Text)
  9304.                 if point and num then
  9305.                     num = math.clamp(num,0,5)
  9306.                     local maxEnvelope = math.min(point[1],10-point[1])
  9307.                     point[3] = math.min(num,maxEnvelope)
  9308.                     redraw()
  9309.                     buildSequence()
  9310.                     updateInputs(point)
  9311.                 end
  9312.             end)
  9313.  
  9314.             local function buttonAnimations(button,inverse)
  9315.                 button.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then button.BackgroundTransparency = (inverse and 0.5 or 0.4) end end)
  9316.                 button.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then button.BackgroundTransparency = (inverse and 1 or 0) end end)
  9317.             end
  9318.  
  9319.             numberLine.InputBegan:Connect(function(input)
  9320.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and #points < 20 then
  9321.                     if Lib.CheckMouseInGui(envelopeDragTop) or Lib.CheckMouseInGui(envelopeDragBottom) then return end
  9322.                     for i,v in pairs(points) do
  9323.                         if Lib.CheckMouseInGui(v[4].Select) then return end
  9324.                     end
  9325.                     local maxX = numberLine.AbsoluteSize.X-1
  9326.                     local relativeX = mouse.X - numberLine.AbsolutePosition.X
  9327.                     if relativeX < 0 then relativeX = 0 end
  9328.                     if relativeX > maxX then relativeX = maxX end
  9329.                     local maxY = numberLine.AbsoluteSize.Y-1
  9330.                     local relativeY = mouse.Y - numberLine.AbsolutePosition.Y
  9331.                     if relativeY < 0 then relativeY = 0 end
  9332.                     if relativeY > maxY then relativeY = maxY end
  9333.  
  9334.                     local raw = relativeX/maxX
  9335.                     local newPoint = {10-(relativeY/maxY)*10,raw,0}
  9336.                     newPoint[4] = placePoint(newPoint)
  9337.                     table.insert(points,newPoint)
  9338.                     redraw()
  9339.                     buildSequence()
  9340.                 end
  9341.             end)
  9342.  
  9343.             deleteButton.MouseButton1Click:Connect(function()
  9344.                 if currentPoint and currentPoint ~= beginPoint and currentPoint ~= endPoint then
  9345.                     for i,v in pairs(points) do
  9346.                         if v == currentPoint then
  9347.                             v[4]:Destroy()
  9348.                             table.remove(points,i)
  9349.                             break
  9350.                         end
  9351.                     end
  9352.                     currentlySelected = nil
  9353.                     redraw()
  9354.                     buildSequence()
  9355.                     updateInputs(points[1])
  9356.                 end
  9357.             end)
  9358.  
  9359.             resetButton.MouseButton1Click:Connect(function()
  9360.                 if resetSequence then
  9361.                     newMt:SetSequence(resetSequence)
  9362.                     buildSequence()
  9363.                 end
  9364.             end)
  9365.  
  9366.             closeButton.MouseButton1Click:Connect(function()
  9367.                 window:Close()
  9368.             end)
  9369.  
  9370.             buttonAnimations(deleteButton)
  9371.             buttonAnimations(resetButton)
  9372.             buttonAnimations(closeButton)
  9373.  
  9374.             placePoints()
  9375.             redraw()
  9376.  
  9377.             newMt.Show = function(self)
  9378.                 window:Show()
  9379.             end
  9380.  
  9381.             return newMt
  9382.         end
  9383.  
  9384.         return {new = new}
  9385.     end)()
  9386.  
  9387.     Lib.ColorSequenceEditor = (function() -- TODO: Convert to newer class model
  9388.         local function new()
  9389.             local newMt = setmetatable({},{})
  9390.             newMt.OnSelect = Lib.Signal.new()
  9391.             newMt.OnCancel = Lib.Signal.new()
  9392.             newMt.OnPreview = Lib.Signal.new()
  9393.             newMt.OnPickColor = Lib.Signal.new()
  9394.  
  9395.             local guiContents = create({
  9396.                 {1,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,ClipsDescendants=true,Name="Content",Position=UDim2.new(0,0,0,20),Size=UDim2.new(1,0,1,-20),}},
  9397.                 {2,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Name="ColorLine",Parent={1},Position=UDim2.new(0,10,0,5),Size=UDim2.new(1,-20,0,70),}},
  9398.                 {3,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0,Name="Gradient",Parent={2},Size=UDim2.new(1,0,1,0),}},
  9399.                 {4,"UIGradient",{Parent={3},}},
  9400.                 {5,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Name="Arrows",Parent={1},Position=UDim2.new(0,1,0,73),Size=UDim2.new(1,-2,0,16),}},
  9401.                 {6,"Frame",{BackgroundColor3=Color3.new(0,0,0),BackgroundTransparency=0.5,BorderSizePixel=0,Name="Cursor",Parent={1},Position=UDim2.new(0,10,0,0),Size=UDim2.new(0,1,0,80),}},
  9402.                 {7,"Frame",{BackgroundColor3=Color3.new(0.14901961386204,0.14901961386204,0.14901961386204),BorderColor3=Color3.new(0.12549020349979,0.12549020349979,0.12549020349979),Name="Time",Parent={1},Position=UDim2.new(0,40,0,95),Size=UDim2.new(0,100,0,20),}},
  9403.                 {8,"TextBox",{BackgroundColor3=Color3.new(0.25098040699959,0.25098040699959,0.25098040699959),BackgroundTransparency=1,BorderColor3=Color3.new(0.37647062540054,0.37647062540054,0.37647062540054),ClipsDescendants=true,Font=3,Name="Input",Parent={7},Position=UDim2.new(0,2,0,0),Size=UDim2.new(0,98,0,20),Text="0",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=0,}},
  9404.                 {9,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={7},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Time",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  9405.                 {10,"Frame",{BackgroundColor3=Color3.new(1,1,1),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),Name="ColorBox",Parent={1},Position=UDim2.new(0,220,0,95),Size=UDim2.new(0,20,0,20),}},
  9406.                 {11,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Title",Parent={10},Position=UDim2.new(0,-40,0,0),Size=UDim2.new(0,34,1,0),Text="Color",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,TextXAlignment=1,}},
  9407.                 {12,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),BorderSizePixel=0,Font=3,Name="Close",Parent={1},Position=UDim2.new(1,-90,0,95),Size=UDim2.new(0,80,0,20),Text="Close",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  9408.                 {13,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),BorderSizePixel=0,Font=3,Name="Reset",Parent={1},Position=UDim2.new(1,-180,0,95),Size=UDim2.new(0,80,0,20),Text="Reset",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  9409.                 {14,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderColor3=Color3.new(0.21568627655506,0.21568627655506,0.21568627655506),BorderSizePixel=0,Font=3,Name="Delete",Parent={1},Position=UDim2.new(0,280,0,95),Size=UDim2.new(0,80,0,20),Text="Delete",TextColor3=Color3.new(0.86274516582489,0.86274516582489,0.86274516582489),TextSize=14,}},
  9410.                 {15,"Frame",{BackgroundTransparency=1,Name="Arrow",Parent={1},Size=UDim2.new(0,16,0,16),Visible=false,}},
  9411.                 {16,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={15},Position=UDim2.new(0,8,0,3),Size=UDim2.new(0,1,0,2),}},
  9412.                 {17,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={15},Position=UDim2.new(0,7,0,5),Size=UDim2.new(0,3,0,2),}},
  9413.                 {18,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={15},Position=UDim2.new(0,6,0,7),Size=UDim2.new(0,5,0,2),}},
  9414.                 {19,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={15},Position=UDim2.new(0,5,0,9),Size=UDim2.new(0,7,0,2),}},
  9415.                 {20,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={15},Position=UDim2.new(0,4,0,11),Size=UDim2.new(0,9,0,2),}},
  9416.             })
  9417.             local window = Lib.Window.new()
  9418.             window.Resizable = false
  9419.             window:Resize(650,150)
  9420.             window:SetTitle("ColorSequence Editor")
  9421.             newMt.Window = window
  9422.             newMt.Gui = window.Gui
  9423.             for i,v in pairs(guiContents:GetChildren()) do
  9424.                 v.Parent = window.GuiElems.Content
  9425.             end
  9426.             local gui = window.Gui
  9427.             local pickerGui = gui.Main
  9428.             local pickerTopBar = pickerGui.TopBar
  9429.             local pickerFrame = pickerGui.Content
  9430.             local colorLine = pickerFrame.ColorLine
  9431.             local gradient = colorLine.Gradient.UIGradient
  9432.             local arrowFrame = pickerFrame.Arrows
  9433.             local arrow = pickerFrame.Arrow
  9434.             local cursor = pickerFrame.Cursor
  9435.             local timeBox = pickerFrame.Time.Input
  9436.             local colorBox = pickerFrame.ColorBox
  9437.             local deleteButton = pickerFrame.Delete
  9438.             local resetButton = pickerFrame.Reset
  9439.             local closeButton = pickerFrame.Close
  9440.             local topClose = pickerTopBar.Close
  9441.  
  9442.             local user = cloneref(game["Run Service"].Parent:GetService("UserInputService"))
  9443.             local mouse = cloneref(game["Run Service"].Parent:GetService("Players")).LocalPlayer:GetMouse()
  9444.  
  9445.             local colors = {{Color3.new(1,0,1),0},{Color3.new(0.2,0.9,0.2),0.2},{Color3.new(0.4,0.5,0.9),0.7},{Color3.new(0.6,1,1),1}}
  9446.             local resetSequence = nil
  9447.  
  9448.             local beginPoint = colors[1]
  9449.             local endPoint = colors[#colors]
  9450.  
  9451.             local currentlySelected = nil
  9452.             local currentPoint = nil
  9453.  
  9454.             local sequenceLine = Instance.new("Frame")
  9455.             sequenceLine.BorderSizePixel = 0
  9456.             sequenceLine.Size = UDim2.new(0,1,1,0)
  9457.  
  9458.             newMt.Sequence = ColorSequence.new(Color3.new(1,1,1))
  9459.             local function buildSequence(noupdate)
  9460.                 local newPoints = {}
  9461.                 table.sort(colors,function(a,b) return a[2] < b[2] end)
  9462.                 for i,v in pairs(colors) do
  9463.                     table.insert(newPoints,ColorSequenceKeypoint.new(v[2],v[1]))
  9464.                 end
  9465.                 newMt.Sequence = ColorSequence.new(newPoints)
  9466.                 if not noupdate then newMt.OnSelect:Fire(newMt.Sequence) end
  9467.             end
  9468.  
  9469.             local function round(num,places)
  9470.                 local multi = 10^places
  9471.                 return math.floor(num*multi + 0.5)/multi
  9472.             end
  9473.  
  9474.             local function updateInputs(point)
  9475.                 if point then
  9476.                     currentPoint = point
  9477.                     local raw = point[2]
  9478.                     timeBox.Text = round(raw,(raw < 0.01 and 5) or (raw < 0.1 and 4) or 3)
  9479.                     colorBox.BackgroundColor3 = point[1]
  9480.                 end
  9481.             end
  9482.  
  9483.             local function placeArrow(ind,point)
  9484.                 local newArrow = arrow:Clone()
  9485.                 newArrow.Position = UDim2.new(0,ind-1,0,0)
  9486.                 newArrow.Visible = true
  9487.                 newArrow.Parent = arrowFrame
  9488.  
  9489.                 newArrow.InputBegan:Connect(function(input)
  9490.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  9491.                         cursor.Visible = true
  9492.                         cursor.Position = UDim2.new(0,9 + newArrow.Position.X.Offset,0,0)
  9493.                     end
  9494.                     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  9495.                         updateInputs(point)
  9496.                         if point == beginPoint or point == endPoint or currentlySelected then return end
  9497.  
  9498.                         local mouseEvent,releaseEvent
  9499.                         currentlySelected = true
  9500.  
  9501.                         releaseEvent = user.InputEnded:Connect(function(input)
  9502.                             if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
  9503.                             mouseEvent:Disconnect()
  9504.                             releaseEvent:Disconnect()
  9505.                             currentlySelected = nil
  9506.                             cursor.Visible = false
  9507.                         end)
  9508.  
  9509.                         mouseEvent = user.InputChanged:Connect(function(input)
  9510.                             if input.UserInputType == Enum.UserInputType.MouseMovement then
  9511.                                 local maxSize = colorLine.AbsoluteSize.X-1
  9512.                                 local relativeX = mouse.X - colorLine.AbsolutePosition.X
  9513.                                 if relativeX < 0 then relativeX = 0 end
  9514.                                 if relativeX > maxSize then relativeX = maxSize end
  9515.                                 local raw = relativeX/maxSize
  9516.                                 point[2] = relativeX/maxSize
  9517.                                 updateInputs(point)
  9518.                                 cursor.Visible = true
  9519.                                 cursor.Position = UDim2.new(0,9 + newArrow.Position.X.Offset,0,0)
  9520.                                 buildSequence()
  9521.                                 newMt:Redraw()
  9522.                             end
  9523.                         end)
  9524.                     end
  9525.                 end)
  9526.  
  9527.                 newArrow.InputEnded:Connect(function(input)
  9528.                     if input.UserInputType == Enum.UserInputType.MouseMovement then
  9529.                         cursor.Visible = false
  9530.                     end
  9531.                 end)
  9532.  
  9533.                 return newArrow
  9534.             end
  9535.  
  9536.             local function placeArrows()
  9537.                 for i,v in pairs(colors) do
  9538.                     v[3] = placeArrow(math.floor((colorLine.AbsoluteSize.X-1) * v[2]) + 1,v)
  9539.                 end
  9540.             end
  9541.  
  9542.             local function redraw(self)
  9543.                 gradient.Color = newMt.Sequence or ColorSequence.new(Color3.new(1,1,1))
  9544.  
  9545.                 for i = 2,#colors do
  9546.                     local nextColor = colors[i]
  9547.                     local endPos = math.floor((colorLine.AbsoluteSize.X-1) * nextColor[2]) + 1
  9548.                     nextColor[3].Position = UDim2.new(0,endPos,0,0)
  9549.                 end    
  9550.             end
  9551.             newMt.Redraw = redraw
  9552.  
  9553.             local function loadSequence(self,seq)
  9554.                 resetSequence = seq
  9555.                 for i,v in pairs(colors) do if v[3] then v[3]:Destroy() end end
  9556.                 colors = {}
  9557.                 currentlySelected = nil
  9558.                 for i,v in pairs(seq.Keypoints) do
  9559.                     local newPoint = {v.Value,v.Time}
  9560.                     newPoint[3] = placeArrow(v.Time,newPoint)
  9561.                     table.insert(colors,newPoint)
  9562.                 end
  9563.                 beginPoint = colors[1]
  9564.                 endPoint = colors[#colors]
  9565.                 currentlySelected = nil
  9566.                 updateInputs(colors[1])
  9567.                 buildSequence(true)
  9568.                 redraw()
  9569.             end
  9570.             newMt.SetSequence = loadSequence
  9571.  
  9572.             local function buttonAnimations(button,inverse)
  9573.                 button.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then button.BackgroundTransparency = (inverse and 0.5 or 0.4) end end)
  9574.                 button.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then button.BackgroundTransparency = (inverse and 1 or 0) end end)
  9575.             end
  9576.  
  9577.             colorLine.InputBegan:Connect(function(input)
  9578.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and #colors < 20 then
  9579.                     local maxSize = colorLine.AbsoluteSize.X-1
  9580.                     local relativeX = mouse.X - colorLine.AbsolutePosition.X
  9581.                     if relativeX < 0 then relativeX = 0 end
  9582.                     if relativeX > maxSize then relativeX = maxSize end
  9583.  
  9584.                     local raw = relativeX/maxSize
  9585.                     local fromColor = nil
  9586.                     local toColor = nil
  9587.                     for i,col in pairs(colors) do
  9588.                         if col[2] >= raw then
  9589.                             fromColor = colors[math.max(i-1,1)]
  9590.                             toColor = colors[i]
  9591.                             break
  9592.                         end
  9593.                     end
  9594.                     local lerpColor = fromColor[1]:lerp(toColor[1],(raw-fromColor[2])/(toColor[2]-fromColor[2]))
  9595.                     local newPoint = {lerpColor,raw}
  9596.                     newPoint[3] = placeArrow(newPoint[2],newPoint)
  9597.                     table.insert(colors,newPoint)
  9598.                     updateInputs(newPoint)
  9599.                     buildSequence()
  9600.                     redraw()
  9601.                 end
  9602.             end)
  9603.  
  9604.             colorLine.InputChanged:Connect(function(input)
  9605.                 if input.UserInputType == Enum.UserInputType.MouseMovement then
  9606.                     local maxSize = colorLine.AbsoluteSize.X-1
  9607.                     local relativeX = mouse.X - colorLine.AbsolutePosition.X
  9608.                     if relativeX < 0 then relativeX = 0 end
  9609.                     if relativeX > maxSize then relativeX = maxSize end
  9610.                     cursor.Visible = true
  9611.                     cursor.Position = UDim2.new(0,10 + relativeX,0,0)
  9612.                 end
  9613.             end)
  9614.  
  9615.             colorLine.InputEnded:Connect(function(input)
  9616.                 if input.UserInputType == Enum.UserInputType.MouseMovement then
  9617.                     local inArrow = false
  9618.                     for i,v in pairs(colors) do
  9619.                         if Lib.CheckMouseInGui(v[3]) then
  9620.                             inArrow = v[3]
  9621.                         end
  9622.                     end
  9623.                     cursor.Visible = inArrow and true or false
  9624.                     if inArrow then cursor.Position = UDim2.new(0,9 + inArrow.Position.X.Offset,0,0) end
  9625.                 end
  9626.             end)
  9627.  
  9628.             timeBox:GetPropertyChangedSignal("Text"):Connect(function()
  9629.                 local point = currentPoint
  9630.                 local num = tonumber(timeBox.Text)
  9631.                 if point and num and point ~= beginPoint and point ~= endPoint then
  9632.                     num = math.clamp(num,0,1)
  9633.                     point[2] = num
  9634.                     buildSequence()
  9635.                     redraw()
  9636.                 end
  9637.             end)
  9638.  
  9639.             colorBox.InputBegan:Connect(function(input)
  9640.                 if input.UserInputType == Enum.UserInputType.MouseButton1 then
  9641.                     local editor = newMt.ColorPicker
  9642.                     if not editor then
  9643.                         editor = Lib.ColorPicker.new()
  9644.                         editor.Window:SetTitle("ColorSequence Color Picker")
  9645.  
  9646.                         editor.OnSelect:Connect(function(col)
  9647.                             if currentPoint then
  9648.                                 currentPoint[1] = col
  9649.                             end
  9650.                             buildSequence()
  9651.                             redraw()
  9652.                         end)
  9653.  
  9654.                         newMt.ColorPicker = editor
  9655.                     end
  9656.  
  9657.                     editor.Window:ShowAndFocus()
  9658.                 end
  9659.             end)
  9660.  
  9661.             deleteButton.MouseButton1Click:Connect(function()
  9662.                 if currentPoint and currentPoint ~= beginPoint and currentPoint ~= endPoint then
  9663.                     for i,v in pairs(colors) do
  9664.                         if v == currentPoint then
  9665.                             v[3]:Destroy()
  9666.                             table.remove(colors,i)
  9667.                             break
  9668.                         end
  9669.                     end
  9670.                     currentlySelected = nil
  9671.                     updateInputs(colors[1])
  9672.                     buildSequence()
  9673.                     redraw()
  9674.                 end
  9675.             end)
  9676.  
  9677.             resetButton.MouseButton1Click:Connect(function()
  9678.                 if resetSequence then
  9679.                     newMt:SetSequence(resetSequence)
  9680.                 end
  9681.             end)
  9682.  
  9683.             closeButton.MouseButton1Click:Connect(function()
  9684.                 window:Close()
  9685.             end)
  9686.  
  9687.             topClose.MouseButton1Click:Connect(function()
  9688.                 window:Close()
  9689.             end)
  9690.  
  9691.             buttonAnimations(deleteButton)
  9692.             buttonAnimations(resetButton)
  9693.             buttonAnimations(closeButton)
  9694.  
  9695.             placeArrows()
  9696.             redraw()
  9697.  
  9698.             newMt.Show = function(self)
  9699.                 window:Show()
  9700.             end
  9701.  
  9702.             return newMt
  9703.         end
  9704.  
  9705.         return {new = new}
  9706.     end)()
  9707.  
  9708.     Lib.ViewportTextBox = (function()
  9709.         local textService = cloneref(game["Run Service"].Parent:GetService("TextService"))
  9710.  
  9711.         local props = {
  9712.             OffsetX = 0,
  9713.             TextBox = PH,
  9714.             CursorPos = -1,
  9715.             Gui = PH,
  9716.             View = PH
  9717.         }
  9718.         local funcs = {}
  9719.         funcs.Update = function(self)
  9720.             local cursorPos = self.CursorPos or -1
  9721.             local text = self.TextBox.Text
  9722.             if text == "" then self.TextBox.Position = UDim2.new(0,0,0,0) return end
  9723.             if cursorPos == -1 then return end
  9724.  
  9725.             local cursorText = text:sub(1,cursorPos-1)
  9726.             local pos = nil
  9727.             local leftEnd = -self.TextBox.Position.X.Offset
  9728.             local rightEnd = leftEnd + self.View.AbsoluteSize.X
  9729.  
  9730.             local totalTextSize = textService:GetTextSize(text,self.TextBox.TextSize,self.TextBox.Font,Vector2.new(999999999,100)).X
  9731.             local cursorTextSize = textService:GetTextSize(cursorText,self.TextBox.TextSize,self.TextBox.Font,Vector2.new(999999999,100)).X
  9732.  
  9733.             if cursorTextSize > rightEnd then
  9734.                 pos = math.max(-1,cursorTextSize - self.View.AbsoluteSize.X + 2)
  9735.             elseif cursorTextSize < leftEnd then
  9736.                 pos = math.max(-1,cursorTextSize-2)
  9737.             elseif totalTextSize < rightEnd then
  9738.                 pos = math.max(-1,totalTextSize - self.View.AbsoluteSize.X + 2)
  9739.             end
  9740.  
  9741.             if pos then
  9742.                 self.TextBox.Position = UDim2.new(0,-pos,0,0)
  9743.                 self.TextBox.Size = UDim2.new(1,pos,1,0)
  9744.             end
  9745.         end
  9746.  
  9747.         funcs.GetText = function(self)
  9748.             return self.TextBox.Text
  9749.         end
  9750.  
  9751.         funcs.SetText = function(self,text)
  9752.             self.TextBox.Text = text
  9753.         end
  9754.  
  9755.         local mt = getGuiMT(props,funcs)
  9756.  
  9757.         local function convert(textbox)
  9758.             local obj = initObj(props,mt)
  9759.  
  9760.             local view = Instance.new("Frame")
  9761.             view.BackgroundTransparency = textbox.BackgroundTransparency
  9762.             view.BackgroundColor3 = textbox.BackgroundColor3
  9763.             view.BorderSizePixel = textbox.BorderSizePixel
  9764.             view.BorderColor3 = textbox.BorderColor3
  9765.             view.Position = textbox.Position
  9766.             view.Size = textbox.Size
  9767.             view.ClipsDescendants = true
  9768.             view.Name = textbox.Name
  9769.             textbox.BackgroundTransparency = 1
  9770.             textbox.Position = UDim2.new(0,0,0,0)
  9771.             textbox.Size = UDim2.new(1,0,1,0)
  9772.             textbox.TextXAlignment = Enum.TextXAlignment.Left
  9773.             textbox.Name = "Input"
  9774.  
  9775.             obj.TextBox = textbox
  9776.             obj.View = view
  9777.             obj.Gui = view
  9778.  
  9779.             textbox.Changed:Connect(function(prop)
  9780.                 if prop == "Text" or prop == "CursorPosition" or prop == "AbsoluteSize" then
  9781.                     local cursorPos = obj.TextBox.CursorPosition
  9782.                     if cursorPos ~= -1 then obj.CursorPos = cursorPos end
  9783.                     obj:Update()
  9784.                 end
  9785.             end)
  9786.  
  9787.             obj:Update()
  9788.  
  9789.             view.Parent = textbox.Parent
  9790.             textbox.Parent = view
  9791.  
  9792.             return obj
  9793.         end
  9794.  
  9795.         local function new()
  9796.             local textBox = Instance.new("TextBox")
  9797.             textBox.Size = UDim2.new(0,100,0,20)
  9798.             textBox.BackgroundColor3 = Settings.Theme.TextBox
  9799.             textBox.BorderColor3 = Settings.Theme.Outline3
  9800.             textBox.ClearTextOnFocus = false
  9801.             textBox.TextColor3 = Settings.Theme.Text
  9802.             textBox.Font = Enum.Font.SourceSans
  9803.             textBox.TextSize = 14
  9804.             textBox.Text = ""
  9805.             return convert(textBox)
  9806.         end
  9807.  
  9808.         return {new = new, convert = convert}
  9809.     end)()
  9810.  
  9811.     Lib.Label = (function()
  9812.         local props,funcs = {},{}
  9813.  
  9814.         local mt = getGuiMT(props,funcs)
  9815.  
  9816.         local function new()
  9817.             local label = Instance.new("TextLabel")
  9818.             label.BackgroundTransparency = 1
  9819.             label.TextXAlignment = Enum.TextXAlignment.Left
  9820.             label.TextColor3 = Settings.Theme.Text
  9821.             label.TextTransparency = 0.1
  9822.             label.Size = UDim2.new(0,100,0,20)
  9823.             label.Font = Enum.Font.SourceSans
  9824.             label.TextSize = 14
  9825.  
  9826.             local obj = setmetatable({
  9827.                 Gui = label
  9828.             },mt)
  9829.             return obj
  9830.         end
  9831.  
  9832.         return {new = new}
  9833.     end)()
  9834.  
  9835.     Lib.Frame = (function()
  9836.         local props,funcs = {},{}
  9837.  
  9838.         local mt = getGuiMT(props,funcs)
  9839.  
  9840.         local function new()
  9841.             local fr = Instance.new("Frame")
  9842.             fr.BackgroundColor3 = Settings.Theme.Main1
  9843.             fr.BorderColor3 = Settings.Theme.Outline1
  9844.             fr.Size = UDim2.new(0,50,0,50)
  9845.  
  9846.             local obj = setmetatable({
  9847.                 Gui = fr
  9848.             },mt)
  9849.             return obj
  9850.         end
  9851.  
  9852.         return {new = new}
  9853.     end)()
  9854.  
  9855.     Lib.Button = (function()
  9856.         local props = {
  9857.             Gui = PH,
  9858.             Anim = PH,
  9859.             Disabled = false,
  9860.             OnClick = SIGNAL,
  9861.             OnDown = SIGNAL,
  9862.             OnUp = SIGNAL,
  9863.             AllowedButtons = {1}
  9864.         }
  9865.         local funcs = {}
  9866.         local tableFind = table.find
  9867.  
  9868.         funcs.Trigger = function(self,event,button)
  9869.             if not self.Disabled and tableFind(self.AllowedButtons,button) then
  9870.                 self["On"..event]:Fire(button)
  9871.             end
  9872.         end
  9873.  
  9874.         funcs.SetDisabled = function(self,dis)
  9875.             self.Disabled = dis
  9876.  
  9877.             if dis then
  9878.                 self.Anim:Disable()
  9879.                 self.Gui.TextTransparency = 0.5
  9880.             else
  9881.                 self.Anim.Enable()
  9882.                 self.Gui.TextTransparency = 0
  9883.             end
  9884.         end
  9885.  
  9886.         local mt = getGuiMT(props,funcs)
  9887.  
  9888.         local function new()
  9889.             local b = Instance.new("TextButton")
  9890.             b.AutoButtonColor = false
  9891.             b.TextColor3 = Settings.Theme.Text
  9892.             b.TextTransparency = 0.1
  9893.             b.Size = UDim2.new(0,100,0,20)
  9894.             b.Font = Enum.Font.SourceSans
  9895.             b.TextSize = 14
  9896.             b.BackgroundColor3 = Settings.Theme.Button
  9897.             b.BorderColor3 = Settings.Theme.Outline2
  9898.  
  9899.             local obj = initObj(props,mt)
  9900.             obj.Gui = b
  9901.             obj.Anim = Lib.ButtonAnim(b,{Mode = 2, StartColor = Settings.Theme.Button, HoverColor = Settings.Theme.ButtonHover, PressColor = Settings.Theme.ButtonPress, OutlineColor = Settings.Theme.Outline2})
  9902.  
  9903.             b.MouseButton1Click:Connect(function() obj:Trigger("Click",1) end)
  9904.             b.MouseButton1Down:Connect(function() obj:Trigger("Down",1) end)
  9905.             b.MouseButton1Up:Connect(function() obj:Trigger("Up",1) end)
  9906.  
  9907.             b.MouseButton2Click:Connect(function() obj:Trigger("Click",2) end)
  9908.             b.MouseButton2Down:Connect(function() obj:Trigger("Down",2) end)
  9909.             b.MouseButton2Up:Connect(function() obj:Trigger("Up",2) end)
  9910.  
  9911.             return obj
  9912.         end
  9913.  
  9914.         return {new = new}
  9915.     end)()
  9916.  
  9917.     Lib.DropDown = (function()
  9918.         local props = {
  9919.             Gui = PH,
  9920.             Anim = PH,
  9921.             Context = PH,
  9922.             Selected = PH,
  9923.             Disabled = false,
  9924.             CanBeEmpty = true,
  9925.             Options = {},
  9926.             GuiElems = {},
  9927.             OnSelect = SIGNAL
  9928.         }
  9929.         local funcs = {}
  9930.  
  9931.         funcs.Update = function(self)
  9932.             local options = self.Options
  9933.  
  9934.             if #options > 0 then
  9935.                 if not self.Selected then
  9936.                     if not self.CanBeEmpty then
  9937.                         self.Selected = options[1]
  9938.                         self.GuiElems.Label.Text = options[1]
  9939.                     else
  9940.                         self.GuiElems.Label.Text = "- Select -"
  9941.                     end
  9942.                 else
  9943.                     self.GuiElems.Label.Text = self.Selected
  9944.                 end
  9945.             else
  9946.                 self.GuiElems.Label.Text = "- Select -"
  9947.             end
  9948.         end
  9949.  
  9950.         funcs.ShowOptions = function(self)
  9951.             local context = self.Context
  9952.  
  9953.             context.Width = self.Gui.AbsoluteSize.X
  9954.             context.ReverseYOffset = self.Gui.AbsoluteSize.Y
  9955.             context:Show(self.Gui.AbsolutePosition.X, self.Gui.AbsolutePosition.Y + context.ReverseYOffset)
  9956.         end
  9957.  
  9958.         funcs.SetOptions = function(self,opts)
  9959.             self.Options = opts
  9960.  
  9961.             local context = self.Context
  9962.             local options = self.Options
  9963.             context:Clear()
  9964.  
  9965.             local onClick = function(option) self.Selected = option self.OnSelect:Fire(option) self:Update() end
  9966.  
  9967.             if self.CanBeEmpty then
  9968.                 context:Add({Name = "- Select -", OnClick = function() self.Selected = nil self.OnSelect:Fire(nil) self:Update() end})
  9969.             end
  9970.  
  9971.             for i = 1,#options do
  9972.                 context:Add({Name = options[i], OnClick = onClick})
  9973.             end
  9974.  
  9975.             self:Update()
  9976.         end
  9977.  
  9978.         funcs.SetSelected = function(self,opt)
  9979.             self.Selected = type(opt) == "number" and self.Options[opt] or opt
  9980.             self:Update()
  9981.         end
  9982.  
  9983.         local mt = getGuiMT(props,funcs)
  9984.  
  9985.         local function new()
  9986.             local f = Instance.new("TextButton")
  9987.             f.AutoButtonColor = false
  9988.             f.Text = ""
  9989.             f.Size = UDim2.new(0,100,0,20)
  9990.             f.BackgroundColor3 = Settings.Theme.TextBox
  9991.             f.BorderColor3 = Settings.Theme.Outline3
  9992.  
  9993.             local label = Lib.Label.new()
  9994.             label.Position = UDim2.new(0,2,0,0)
  9995.             label.Size = UDim2.new(1,-22,1,0)
  9996.             label.TextTruncate = Enum.TextTruncate.AtEnd
  9997.             label.Parent = f
  9998.             local arrow = create({
  9999.                 {1,"Frame",{BackgroundTransparency=1,Name="EnumArrow",Position=UDim2.new(1,-16,0,2),Size=UDim2.new(0,16,0,16),}},
  10000.                 {2,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,8,0,9),Size=UDim2.new(0,1,0,1),}},
  10001.                 {3,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,7,0,8),Size=UDim2.new(0,3,0,1),}},
  10002.                 {4,"Frame",{BackgroundColor3=Color3.new(0.86274510622025,0.86274510622025,0.86274510622025),BorderSizePixel=0,Parent={1},Position=UDim2.new(0,6,0,7),Size=UDim2.new(0,5,0,1),}},
  10003.             })
  10004.             arrow.Parent = f
  10005.  
  10006.             local obj = initObj(props,mt)
  10007.             obj.Gui = f
  10008.             obj.Anim = Lib.ButtonAnim(f,{Mode = 2, StartColor = Settings.Theme.TextBox, LerpTo = Settings.Theme.Button, LerpDelta = 0.15})
  10009.             obj.Context = Lib.ContextMenu.new()
  10010.             obj.Context.Iconless = true
  10011.             obj.Context.MaxHeight = 200
  10012.             obj.Selected = nil
  10013.             obj.GuiElems = {Label = label}
  10014.             f.MouseButton1Down:Connect(function() obj:ShowOptions() end)
  10015.             obj:Update()
  10016.             return obj
  10017.         end
  10018.  
  10019.         return {new = new}
  10020.     end)()
  10021.  
  10022.     Lib.ClickSystem = (function()
  10023.         local props = {
  10024.             LastItem = PH,
  10025.             OnDown = SIGNAL,
  10026.             OnRelease = SIGNAL,
  10027.             AllowedButtons = {1},
  10028.             Combo = 0,
  10029.             MaxCombo = 2,
  10030.             ComboTime = 0.5,
  10031.             Items = {},
  10032.             ItemCons = {},
  10033.             ClickId = -1,
  10034.             LastButton = ""
  10035.         }
  10036.         local funcs = {}
  10037.         local tostring = tostring
  10038.  
  10039.         local disconnect = function(con)
  10040.             local pos = table.find(con.Signal.Connections,con)
  10041.             if pos then table.remove(con.Signal.Connections,pos) end
  10042.         end
  10043.  
  10044.         funcs.Trigger = function(self,item,button)
  10045.             if table.find(self.AllowedButtons,button) then
  10046.                 if self.LastButton ~= button or self.LastItem ~= item or self.Combo == self.MaxCombo or tick() - self.ClickId > self.ComboTime then
  10047.                     self.Combo = 0
  10048.                     self.LastButton = button
  10049.                     self.LastItem = item
  10050.                 end
  10051.                 self.Combo = self.Combo + 1
  10052.                 self.ClickId = tick()
  10053.  
  10054.                 local release
  10055.                 release = service.UserInputService.InputEnded:Connect(function(input)
  10056.                     if input.UserInputType == Enum.UserInputType["MouseButton"..button] then
  10057.                         release:Disconnect()
  10058.                         if Lib.CheckMouseInGui(item) and self.LastButton == button and self.LastItem == item then
  10059.                             self["OnRelease"]:Fire(item,self.Combo,button)
  10060.                         end
  10061.                     end
  10062.                 end)
  10063.  
  10064.                 self["OnDown"]:Fire(item,self.Combo,button)
  10065.             end
  10066.         end
  10067.  
  10068.         funcs.Add = function(self,item)
  10069.             if table.find(self.Items,item) then return end
  10070.  
  10071.             local cons = {}
  10072.             cons[1] = item.MouseButton1Down:Connect(function() self:Trigger(item,1) end)
  10073.             cons[2] = item.MouseButton2Down:Connect(function() self:Trigger(item,2) end)
  10074.  
  10075.             self.ItemCons[item] = cons
  10076.             self.Items[#self.Items+1] = item
  10077.         end
  10078.  
  10079.         funcs.Remove = function(self,item)
  10080.             local ind = table.find(self.Items,item)
  10081.             if not ind then return end
  10082.  
  10083.             for i,v in pairs(self.ItemCons[item]) do
  10084.                 v:Disconnect()
  10085.             end
  10086.             self.ItemCons[item] = nil
  10087.             table.remove(self.Items,ind)
  10088.         end
  10089.  
  10090.         local mt = {__index = funcs}
  10091.  
  10092.         local function new()
  10093.             local obj = initObj(props,mt)
  10094.  
  10095.             return obj
  10096.         end
  10097.  
  10098.         return {new = new}
  10099.     end)()
  10100.  
  10101.     return Lib
  10102. end
  10103.  
  10104. return {InitDeps = initDeps, InitAfterMain = initAfterMain, Main = main}
  10105. end
  10106. }
  10107.  
  10108. -- Main vars
  10109. local Main, Explorer, Properties, ScriptViewer, DefaultSettings, Notebook, Serializer, Lib
  10110. local API, RMD
  10111.  
  10112. -- Default Settings
  10113. DefaultSettings = (function()
  10114.     local rgb = Color3.fromRGB
  10115.     return {
  10116.         Explorer = {
  10117.             _Recurse = true,
  10118.             Sorting = true,
  10119.             TeleportToOffset = Vector3.new(0,0,0),
  10120.             ClickToRename = true,
  10121.             AutoUpdateSearch = true,
  10122.             AutoUpdateMode = 0, -- 0 Default, 1 no tree update, 2 no descendant events, 3 frozen
  10123.             PartSelectionBox = true,
  10124.             GuiSelectionBox = true,
  10125.             CopyPathUseGetChildren = true
  10126.         },
  10127.         Properties = {
  10128.             _Recurse = true,
  10129.             MaxConflictCheck = 50,
  10130.             ShowDeprecated = false,
  10131.             ShowHidden = false,
  10132.             ClearOnFocus = false,
  10133.             LoadstringInput = true,
  10134.             NumberRounding = 3,
  10135.             ShowAttributes = false,
  10136.             MaxAttributes = 50,
  10137.             ScaleType = 1 -- 0 Full Name Shown, 1 Equal Halves
  10138.         },
  10139.         Theme = {
  10140.             _Recurse = true,
  10141.             Main1 = rgb(52,52,52),
  10142.             Main2 = rgb(45,45,45),
  10143.             Outline1 = rgb(33,33,33), -- Mainly frames
  10144.             Outline2 = rgb(55,55,55), -- Mainly button
  10145.             Outline3 = rgb(30,30,30), -- Mainly textbox
  10146.             TextBox = rgb(38,38,38),
  10147.             Menu = rgb(32,32,32),
  10148.             ListSelection = rgb(11,90,175),
  10149.             Button = rgb(60,60,60),
  10150.             ButtonHover = rgb(68,68,68),
  10151.             ButtonPress = rgb(40,40,40),
  10152.             Highlight = rgb(75,75,75),
  10153.             Text = rgb(255,255,255),
  10154.             PlaceholderText = rgb(100,100,100),
  10155.             Important = rgb(255,0,0),
  10156.             ExplorerIconMap = "",
  10157.             MiscIconMap = "",
  10158.             Syntax = {
  10159.                 Text = rgb(204,204,204),
  10160.                 Background = rgb(36,36,36),
  10161.                 Selection = rgb(255,255,255),
  10162.                 SelectionBack = rgb(11,90,175),
  10163.                 Operator = rgb(204,204,204),
  10164.                 Number = rgb(255,198,0),
  10165.                 String = rgb(173,241,149),
  10166.                 Comment = rgb(102,102,102),
  10167.                 Keyword = rgb(248,109,124),
  10168.                 Error = rgb(255,0,0),
  10169.                 FindBackground = rgb(141,118,0),
  10170.                 MatchingWord = rgb(85,85,85),
  10171.                 BuiltIn = rgb(132,214,247),
  10172.                 CurrentLine = rgb(45,50,65),
  10173.                 LocalMethod = rgb(253,251,172),
  10174.                 LocalProperty = rgb(97,161,241),
  10175.                 Nil = rgb(255,198,0),
  10176.                 Bool = rgb(255,198,0),
  10177.                 Function = rgb(248,109,124),
  10178.                 Local = rgb(248,109,124),
  10179.                 Self = rgb(248,109,124),
  10180.                 FunctionName = rgb(253,251,172),
  10181.                 Bracket = rgb(204,204,204)
  10182.             },
  10183.         }
  10184.     }
  10185. end)()
  10186.  
  10187. -- Vars
  10188. local Settings = {}
  10189. local Apps = {}
  10190. local env = {}
  10191. local service = setmetatable({},{__index = function(self,name)
  10192.     local serv = cloneref(game["Run Service"].Parent:GetService(name))
  10193.     self[name] = serv
  10194.     return serv
  10195. end})
  10196. local plr = service.Players.LocalPlayer or service.Players.PlayerAdded:wait()
  10197.  
  10198. local create = function(data)
  10199.     local insts = {}
  10200.     for i,v in pairs(data) do insts[v[1]] = Instance.new(v[2]) end
  10201.    
  10202.     for _,v in pairs(data) do
  10203.         for prop,val in pairs(v[3]) do
  10204.             if type(val) == "table" then
  10205.                 insts[v[1]][prop] = insts[val[1]]
  10206.             else
  10207.                 insts[v[1]][prop] = val
  10208.             end
  10209.         end
  10210.     end
  10211.    
  10212.     return insts[1]
  10213. end
  10214.  
  10215. local createSimple = function(class,props)
  10216.     local inst = Instance.new(class)
  10217.     for i,v in next,props do
  10218.         inst[i] = v
  10219.     end
  10220.     return inst
  10221. end
  10222.  
  10223. Main = (function()
  10224.     local Main = {}
  10225.    
  10226.     Main.ModuleList = {"Explorer","Properties","ScriptViewer"}
  10227.     Main.Elevated = false
  10228.     Main.MissingEnv = {}
  10229.     Main.Version = "" -- Beta 1.0.0
  10230.     Main.Mouse = plr:GetMouse()
  10231.     Main.AppControls = {}
  10232.     Main.Apps = Apps
  10233.     Main.MenuApps = {}
  10234.    
  10235.     Main.DisplayOrders = {
  10236.         SideWindow = 8,
  10237.         Window = 10,
  10238.         Menu = 100000,
  10239.         Core = 101000
  10240.     }
  10241.    
  10242.     Main.GetInitDeps = function()
  10243.         return {
  10244.             Main = Main,
  10245.             Lib = Lib,
  10246.             Apps = Apps,
  10247.             Settings = Settings,
  10248.            
  10249.             API = API,
  10250.             RMD = RMD,
  10251.             env = env,
  10252.             service = service,
  10253.             plr = plr,
  10254.             create = create,
  10255.             createSimple = createSimple
  10256.         }
  10257.     end
  10258.    
  10259.     Main.Error = function(str)
  10260.         if rconsoleprint then
  10261.             rconsoleprint("DEX ERROR: "..tostring(str).."\n")
  10262.             wait(9e9)
  10263.         else
  10264.             error(str)
  10265.         end
  10266.     end
  10267.    
  10268.     Main.LoadModule = function(name)
  10269.         if Main.Elevated then -- If you don't have filesystem api then ur outta luck tbh
  10270.             local control
  10271.            
  10272.             if EmbeddedModules then -- Offline Modules
  10273.                 control = EmbeddedModules[name]()
  10274.                
  10275.                 if not control then Main.Error("Missing Embedded Module: "..name) end
  10276.             end
  10277.            
  10278.             Main.AppControls[name] = control
  10279.             control.InitDeps(Main.GetInitDeps())
  10280.  
  10281.             local moduleData = control.Main()
  10282.             Apps[name] = moduleData
  10283.             return moduleData
  10284.         else
  10285.             local module = script:WaitForChild("Modules"):WaitForChild(name,2)
  10286.             if not module then Main.Error("CANNOT FIND MODULE "..name) end
  10287.            
  10288.             local control = require(module)
  10289.             Main.AppControls[name] = control
  10290.             control.InitDeps(Main.GetInitDeps())
  10291.            
  10292.             local moduleData = control.Main()
  10293.             Apps[name] = moduleData
  10294.             return moduleData
  10295.         end
  10296.     end
  10297.    
  10298.     Main.LoadModules = function()
  10299.         for i,v in pairs(Main.ModuleList) do
  10300.             local s,e = pcall(Main.LoadModule,v)
  10301.             if not s then
  10302.                 Main.Error("FAILED LOADING " + v + " CAUSE " + e)
  10303.             end
  10304.         end
  10305.        
  10306.         -- Init Major Apps and define them in modules
  10307.         Explorer = Apps.Explorer
  10308.         Properties = Apps.Properties
  10309.         ScriptViewer = Apps.ScriptViewer
  10310.         Notebook = Apps.Notebook
  10311.         local appTable = {
  10312.             Explorer = Explorer,
  10313.             Properties = Properties,
  10314.             ScriptViewer = ScriptViewer,
  10315.             Notebook = Notebook
  10316.         }
  10317.        
  10318.         Main.AppControls.Lib.InitAfterMain(appTable)
  10319.         for i,v in pairs(Main.ModuleList) do
  10320.             local control = Main.AppControls[v]
  10321.             if control then
  10322.                 control.InitAfterMain(appTable)
  10323.             end
  10324.         end
  10325.     end
  10326.  
  10327.     Main.InitEnv = function()
  10328.         setmetatable(env, {__newindex = function(self, name, func)
  10329.             if not func then Main.MissingEnv[#Main.MissingEnv + 1] = name return end
  10330.             rawset(self, name, func)
  10331.         end})
  10332.  
  10333.         -- file
  10334.         env.readfile = readfile
  10335.         env.writefile = writefile
  10336.         env.appendfile = appendfile
  10337.         env.makefolder = makefolder
  10338.         env.listfiles = listfiles
  10339.         env.loadfile = loadfile
  10340.         env.movefileas = movefileas
  10341.         env.saveinstance = saveinstance
  10342.  
  10343.         -- debug
  10344.         env.getupvalues = (debug and debug.getupvalues) or getupvalues or getupvals
  10345.         env.getconstants = (debug and debug.getconstants) or getconstants or getconsts
  10346.         env.getinfo = (debug and (debug.getinfo or debug.info)) or getinfo
  10347.         env.islclosure = islclosure or is_l_closure or is_lclosure
  10348.         env.checkcaller = checkcaller
  10349.         --env.getreg = getreg
  10350.         env.getgc = getgc or get_gc_objects
  10351.         env.base64encode = crypt and crypt.base64 and crypt.base64.encode
  10352.         env.getscriptbytecode = getscriptbytecode
  10353.  
  10354.         -- other
  10355.         --env.setfflag = setfflag
  10356.         env.request = (syn and syn.request) or (http and http.request) or http_request or (fluxus and fluxus.request) or request
  10357.         env.decompile = decompile or (env.getscriptbytecode and env.request and env.base64encode and function(scr)
  10358.             local s, bytecode = pcall(env.getscriptbytecode, scr)
  10359.             if not s then
  10360.                 return "failed to get bytecode " .. tostring(bytecode)
  10361.             end
  10362.  
  10363.             local response = env.request({
  10364.                 Url = "https://unluau.lonegladiator.dev/unluau/decompile",
  10365.                 Method = "POST",
  10366.                 Headers = {
  10367.                     ["Content-Type"] = "application/json"
  10368.                 },
  10369.                 Body = service.HttpService:JSONEncode({
  10370.                     version = 5,
  10371.                     bytecode = env.base64encode(bytecode)
  10372.                 })
  10373.             })
  10374.  
  10375.             local decoded = service.HttpService:JSONDecode(response.Body)
  10376.             if decoded.status ~= "ok" then
  10377.                 return "decompilation failed: " .. tostring(decoded.status)
  10378.             end
  10379.  
  10380.             return decoded.output
  10381.         end)
  10382.         env.protectgui = protect_gui or (syn and syn.protect_gui)
  10383.         env.gethui = gethui or get_hidden_gui
  10384.         env.setclipboard = setclipboard or toclipboard or set_clipboard or (Clipboard and Clipboard.set)
  10385.         env.getnilinstances = getnilinstances or get_nil_instances
  10386.         env.getloadedmodules = getloadedmodules
  10387.  
  10388.         -- if identifyexecutor and type(identifyexecutor) == "function" then Main.Executor = identifyexecutor() end
  10389.  
  10390.         Main.GuiHolder = Main.Elevated and service.CoreGui or plr:FindFirstChildWhichIsA("PlayerGui")
  10391.  
  10392.         setmetatable(env, nil)
  10393.     end
  10394.  
  10395.     Main.LoadSettings = function()
  10396.         local s,data = pcall(env.readfile or error,"DexSettings.json")
  10397.         if s and data and data ~= "" then
  10398.             local s,decoded = service.HttpService:JSONDecode(data)
  10399.             if s and decoded then
  10400.                 for i,v in next,decoded do
  10401.                    
  10402.                 end
  10403.             else
  10404.                 -- TODO: Notification
  10405.             end
  10406.         else
  10407.             Main.ResetSettings()
  10408.         end
  10409.     end
  10410.    
  10411.     Main.ResetSettings = function()
  10412.         local function recur(t,res)
  10413.             for set,val in pairs(t) do
  10414.                 if type(val) == "table" and val._Recurse then
  10415.                     if type(res[set]) ~= "table" then
  10416.                         res[set] = {}
  10417.                     end
  10418.                     recur(val,res[set])
  10419.                 else
  10420.                     res[set] = val
  10421.                 end
  10422.             end
  10423.             return res
  10424.         end
  10425.         recur(DefaultSettings,Settings)
  10426.     end
  10427.    
  10428.     Main.FetchAPI = function()
  10429.         local api,rawAPI
  10430.         if Main.Elevated then
  10431.             if Main.LocalDepsUpToDate() then
  10432.                 local localAPI = Lib.ReadFile("dex/rbx_api.dat")
  10433.                 if localAPI then
  10434.                     rawAPI = localAPI
  10435.                 else
  10436.                     Main.DepsVersionData[1] = ""
  10437.                 end
  10438.             end
  10439.             rawAPI = rawAPI or game:HttpGet("http://setup.roblox.com/"..Main.RobloxVersion.."-API-Dump.json")
  10440.         else
  10441.             if script:FindFirstChild("API") then
  10442.                 rawAPI = require(script.API)
  10443.             else
  10444.                 error("NO API EXISTS")
  10445.             end
  10446.         end
  10447.         Main.RawAPI = rawAPI
  10448.         api = service.HttpService:JSONDecode(rawAPI)
  10449.        
  10450.         local classes,enums = {},{}
  10451.         local categoryOrder,seenCategories = {},{}
  10452.        
  10453.         local function insertAbove(t,item,aboveItem)
  10454.             local findPos = table.find(t,item)
  10455.             if not findPos then return end
  10456.             table.remove(t,findPos)
  10457.  
  10458.             local pos = table.find(t,aboveItem)
  10459.             if not pos then return end
  10460.             table.insert(t,pos,item)
  10461.         end
  10462.        
  10463.         for _,class in pairs(api.Classes) do
  10464.             local newClass = {}
  10465.             newClass.Name = class.Name
  10466.             newClass.Superclass = class.Superclass
  10467.             newClass.Properties = {}
  10468.             newClass.Functions = {}
  10469.             newClass.Events = {}
  10470.             newClass.Callbacks = {}
  10471.             newClass.Tags = {}
  10472.            
  10473.             if class.Tags then for c,tag in pairs(class.Tags) do newClass.Tags[tag] = true end end
  10474.             for __,member in pairs(class.Members) do
  10475.                 local newMember = {}
  10476.                 newMember.Name = member.Name
  10477.                 newMember.Class = class.Name
  10478.                 newMember.Security = member.Security
  10479.                 newMember.Tags ={}
  10480.                 if member.Tags then for c,tag in pairs(member.Tags) do newMember.Tags[tag] = true end end
  10481.                
  10482.                 local mType = member.MemberType
  10483.                 if mType == "Property" then
  10484.                     local propCategory = member.Category or "Other"
  10485.                     propCategory = propCategory:match("^%s*(.-)%s*$")
  10486.                     if not seenCategories[propCategory] then
  10487.                         categoryOrder[#categoryOrder+1] = propCategory
  10488.                         seenCategories[propCategory] = true
  10489.                     end
  10490.                     newMember.ValueType = member.ValueType
  10491.                     newMember.Category = propCategory
  10492.                     newMember.Serialization = member.Serialization
  10493.                     table.insert(newClass.Properties,newMember)
  10494.                 elseif mType == "Function" then
  10495.                     newMember.Parameters = {}
  10496.                     newMember.ReturnType = member.ReturnType.Name
  10497.                     for c,param in pairs(member.Parameters) do
  10498.                         table.insert(newMember.Parameters,{Name = param.Name, Type = param.Type.Name})
  10499.                     end
  10500.                     table.insert(newClass.Functions,newMember)
  10501.                 elseif mType == "Event" then
  10502.                     newMember.Parameters = {}
  10503.                     for c,param in pairs(member.Parameters) do
  10504.                         table.insert(newMember.Parameters,{Name = param.Name, Type = param.Type.Name})
  10505.                     end
  10506.                     table.insert(newClass.Events,newMember)
  10507.                 end
  10508.             end
  10509.            
  10510.             classes[class.Name] = newClass
  10511.         end
  10512.        
  10513.         for _,class in pairs(classes) do
  10514.             class.Superclass = classes[class.Superclass]
  10515.         end
  10516.        
  10517.         for _,enum in pairs(api.Enums) do
  10518.             local newEnum = {}
  10519.             newEnum.Name = enum.Name
  10520.             newEnum.Items = {}
  10521.             newEnum.Tags = {}
  10522.            
  10523.             if enum.Tags then for c,tag in pairs(enum.Tags) do newEnum.Tags[tag] = true end end
  10524.             for __,item in pairs(enum.Items) do
  10525.                 local newItem = {}
  10526.                 newItem.Name = item.Name
  10527.                 newItem.Value = item.Value
  10528.                 table.insert(newEnum.Items,newItem)
  10529.             end
  10530.            
  10531.             enums[enum.Name] = newEnum
  10532.         end
  10533.        
  10534.         local function getMember(class,member)
  10535.             if not classes[class] or not classes[class][member] then return end
  10536.             local result = {}
  10537.    
  10538.             local currentClass = classes[class]
  10539.             while currentClass do
  10540.                 for _,entry in pairs(currentClass[member]) do
  10541.                     result[#result+1] = entry
  10542.                 end
  10543.                 currentClass = currentClass.Superclass
  10544.             end
  10545.    
  10546.             table.sort(result,function(a,b) return a.Name < b.Name end)
  10547.             return result
  10548.         end
  10549.        
  10550.         insertAbove(categoryOrder,"Behavior","Tuning")
  10551.         insertAbove(categoryOrder,"Appearance","Data")
  10552.         insertAbove(categoryOrder,"Attachments","Axes")
  10553.         insertAbove(categoryOrder,"Cylinder","Slider")
  10554.         insertAbove(categoryOrder,"Localization","Jump Settings")
  10555.         insertAbove(categoryOrder,"Surface","Motion")
  10556.         insertAbove(categoryOrder,"Surface Inputs","Surface")
  10557.         insertAbove(categoryOrder,"Part","Surface Inputs")
  10558.         insertAbove(categoryOrder,"Assembly","Surface Inputs")
  10559.         insertAbove(categoryOrder,"Character","Controls")
  10560.         categoryOrder[#categoryOrder+1] = "Unscriptable"
  10561.         categoryOrder[#categoryOrder+1] = "Attributes"
  10562.        
  10563.         local categoryOrderMap = {}
  10564.         for i = 1,#categoryOrder do
  10565.             categoryOrderMap[categoryOrder[i]] = i
  10566.         end
  10567.        
  10568.         return {
  10569.             Classes = classes,
  10570.             Enums = enums,
  10571.             CategoryOrder = categoryOrderMap,
  10572.             GetMember = getMember
  10573.         }
  10574.     end
  10575.    
  10576.     Main.FetchRMD = function()
  10577.         local rawXML
  10578.         if Main.Elevated then
  10579.             if Main.LocalDepsUpToDate() then
  10580.                 local localRMD = Lib.ReadFile("dex/rbx_rmd.dat")
  10581.                 if localRMD then
  10582.                     rawXML = localRMD
  10583.                 else
  10584.                     Main.DepsVersionData[1] = ""
  10585.                 end
  10586.             end
  10587.             rawXML = rawXML or game:HttpGet("https://raw.githubusercontent.com/CloneTrooper1019/Roblox-Client-Tracker/roblox/ReflectionMetadata.xml")
  10588.         else
  10589.             if script:FindFirstChild("RMD") then
  10590.                 rawXML = require(script.RMD)
  10591.             else
  10592.                 error("NO RMD EXISTS")
  10593.             end
  10594.         end
  10595.         Main.RawRMD = rawXML
  10596.         local parsed = Lib.ParseXML(rawXML)
  10597.         local classList = parsed.children[1].children[1].children
  10598.         local enumList = parsed.children[1].children[2].children
  10599.         local propertyOrders = {}
  10600.        
  10601.         local classes,enums = {},{}
  10602.         for _,class in pairs(classList) do
  10603.             local className = ""
  10604.             for _,child in pairs(class.children) do
  10605.                 if child.tag == "Properties" then
  10606.                     local data = {Properties = {}, Functions = {}}
  10607.                     local props = child.children
  10608.                     for _,prop in pairs(props) do
  10609.                         local name = prop.attrs.name
  10610.                         name = name:sub(1,1):upper()..name:sub(2)
  10611.                         data[name] = prop.children[1].text
  10612.                     end
  10613.                     className = data.Name
  10614.                     classes[className] = data
  10615.                 elseif child.attrs.class == "ReflectionMetadataProperties" then
  10616.                     local members = child.children
  10617.                     for _,member in pairs(members) do
  10618.                         if member.attrs.class == "ReflectionMetadataMember" then
  10619.                             local data = {}
  10620.                             if member.children[1].tag == "Properties" then
  10621.                                 local props = member.children[1].children
  10622.                                 for _,prop in pairs(props) do
  10623.                                     if prop.attrs then
  10624.                                         local name = prop.attrs.name
  10625.                                         name = name:sub(1,1):upper()..name:sub(2)
  10626.                                         data[name] = prop.children[1].text
  10627.                                     end
  10628.                                 end
  10629.                                 if data.PropertyOrder then
  10630.                                     local orders = propertyOrders[className]
  10631.                                     if not orders then orders = {} propertyOrders[className] = orders end
  10632.                                     orders[data.Name] = tonumber(data.PropertyOrder)
  10633.                                 end
  10634.                                 classes[className].Properties[data.Name] = data
  10635.                             end
  10636.                         end
  10637.                     end
  10638.                 elseif child.attrs.class == "ReflectionMetadataFunctions" then
  10639.                     local members = child.children
  10640.                     for _,member in pairs(members) do
  10641.                         if member.attrs.class == "ReflectionMetadataMember" then
  10642.                             local data = {}
  10643.                             if member.children[1].tag == "Properties" then
  10644.                                 local props = member.children[1].children
  10645.                                 for _,prop in pairs(props) do
  10646.                                     if prop.attrs then
  10647.                                         local name = prop.attrs.name
  10648.                                         name = name:sub(1,1):upper()..name:sub(2)
  10649.                                         data[name] = prop.children[1].text
  10650.                                     end
  10651.                                 end
  10652.                                 classes[className].Functions[data.Name] = data
  10653.                             end
  10654.                         end
  10655.                     end
  10656.                 end
  10657.             end
  10658.         end
  10659.        
  10660.         for _,enum in pairs(enumList) do
  10661.             local enumName = ""
  10662.             for _,child in pairs(enum.children) do
  10663.                 if child.tag == "Properties" then
  10664.                     local data = {Items = {}}
  10665.                     local props = child.children
  10666.                     for _,prop in pairs(props) do
  10667.                         local name = prop.attrs.name
  10668.                         name = name:sub(1,1):upper()..name:sub(2)
  10669.                         data[name] = prop.children[1].text
  10670.                     end
  10671.                     enumName = data.Name
  10672.                     enums[enumName] = data
  10673.                 elseif child.attrs.class == "ReflectionMetadataEnumItem" then
  10674.                     local data = {}
  10675.                     if child.children[1].tag == "Properties" then
  10676.                         local props = child.children[1].children
  10677.                         for _,prop in pairs(props) do
  10678.                             local name = prop.attrs.name
  10679.                             name = name:sub(1,1):upper()..name:sub(2)
  10680.                             data[name] = prop.children[1].text
  10681.                         end
  10682.                         enums[enumName].Items[data.Name] = data
  10683.                     end
  10684.                 end
  10685.             end
  10686.         end
  10687.        
  10688.         return {Classes = classes, Enums = enums, PropertyOrders = propertyOrders}
  10689.     end
  10690.  
  10691.     Main.ShowGui = function(gui)
  10692.         if env.gethui then
  10693.             gui.Parent = env.gethui()
  10694.         elseif env.protectgui then
  10695.             env.protectgui(gui)
  10696.             gui.Parent = Main.GuiHolder
  10697.         else
  10698.             gui.Parent = Main.GuiHolder
  10699.         end
  10700.     end
  10701.  
  10702.     Main.CreateIntro = function(initStatus) -- TODO: Must theme and show errors
  10703.         local gui = create({
  10704.             {1,"ScreenGui",{Name="Intro",}},
  10705.             {2,"Frame",{Active=true,BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="Main",Parent={1},Position=UDim2.new(0.5,-175,0.5,-100),Size=UDim2.new(0,350,0,200),}},
  10706.             {3,"Frame",{BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,ClipsDescendants=true,Name="Holder",Parent={2},Size=UDim2.new(1,0,1,0),}},
  10707.             {4,"UIGradient",{Parent={3},Rotation=30,Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(1,1,0),}),}},
  10708.             {5,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=4,Name="Title",Parent={3},Position=UDim2.new(0,-190,0,15),Size=UDim2.new(0,100,0,50),Text="Dex",TextColor3=Color3.new(1,1,1),TextSize=50,TextTransparency=1,}},
  10709.             {6,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Desc",Parent={3},Position=UDim2.new(0,-230,0,60),Size=UDim2.new(0,180,0,25),Text="Ultimate Debugging Suite",TextColor3=Color3.new(1,1,1),TextSize=18,TextTransparency=1,}},
  10710.             {7,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="StatusText",Parent={3},Position=UDim2.new(0,20,0,110),Size=UDim2.new(0,180,0,25),Text="Fetching API",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=1,}},
  10711.             {8,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="ProgressBar",Parent={3},Position=UDim2.new(0,110,0,145),Size=UDim2.new(0,0,0,4),}},
  10712.             {9,"Frame",{BackgroundColor3=Color3.new(0.2392156869173,0.56078433990479,0.86274510622025),BorderSizePixel=0,Name="Bar",Parent={8},Size=UDim2.new(0,0,1,0),}},
  10713.             {10,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://2764171053",ImageColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),Parent={8},ScaleType=1,Size=UDim2.new(1,0,1,0),SliceCenter=Rect.new(2,2,254,254),}},
  10714.             {11,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Creator",Parent={2},Position=UDim2.new(1,-110,1,-20),Size=UDim2.new(0,105,0,20),Text="Developed by Moon",TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=1,}},
  10715.             {12,"UIGradient",{Parent={11},Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(1,1,0),}),}},
  10716.             {13,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Version",Parent={2},Position=UDim2.new(1,-110,1,-35),Size=UDim2.new(0,105,0,20),Text=Main.Version,TextColor3=Color3.new(1,1,1),TextSize=14,TextXAlignment=1,}},
  10717.             {14,"UIGradient",{Parent={13},Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(1,1,0),}),}},
  10718.             {15,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Image="rbxassetid://1427967925",Name="Outlines",Parent={2},Position=UDim2.new(0,-5,0,-5),ScaleType=1,Size=UDim2.new(1,10,1,10),SliceCenter=Rect.new(6,6,25,25),TileSize=UDim2.new(0,20,0,20),}},
  10719.             {16,"UIGradient",{Parent={15},Rotation=-30,Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(1,1,0),}),}},
  10720.             {17,"UIGradient",{Parent={2},Rotation=-30,Transparency=NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(1,1,0),}),}},
  10721.         })
  10722.         Main.ShowGui(gui)
  10723.         local backGradient = gui.Main.UIGradient
  10724.         local outlinesGradient = gui.Main.Outlines.UIGradient
  10725.         local holderGradient = gui.Main.Holder.UIGradient
  10726.         local titleText = gui.Main.Holder.Title
  10727.         local descText = gui.Main.Holder.Desc
  10728.         local versionText = gui.Main.Version
  10729.         local versionGradient = versionText.UIGradient
  10730.         local creatorText = gui.Main.Creator
  10731.         local creatorGradient = creatorText.UIGradient
  10732.         local statusText = gui.Main.Holder.StatusText
  10733.         local progressBar = gui.Main.Holder.ProgressBar
  10734.         local tweenS = service.TweenService
  10735.        
  10736.         local renderStepped = service.RunService.RenderStepped
  10737.         local signalWait = renderStepped.wait
  10738.         local fastwait = function(s)
  10739.             if not s then return signalWait(renderStepped) end
  10740.             local start = tick()
  10741.             while tick() - start < s do signalWait(renderStepped) end
  10742.         end
  10743.        
  10744.         statusText.Text = initStatus
  10745.        
  10746.         local function tweenNumber(n,ti,func)
  10747.             local tweenVal = Instance.new("IntValue")
  10748.             tweenVal.Value = 0
  10749.             tweenVal.Changed:Connect(func)
  10750.             local tween = tweenS:Create(tweenVal,ti,{Value = n})
  10751.             tween:Play()
  10752.             tween.Completed:Connect(function()
  10753.                 tweenVal:Destroy()
  10754.             end)
  10755.         end
  10756.        
  10757.         local ti = TweenInfo.new(0.4,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  10758.         tweenNumber(100,ti,function(val)
  10759.                 val = val/200
  10760.                 local start = NumberSequenceKeypoint.new(0,0)
  10761.                 local a1 = NumberSequenceKeypoint.new(val,0)
  10762.                 local a2 = NumberSequenceKeypoint.new(math.min(0.5,val+math.min(0.05,val)),1)
  10763.                 if a1.Time == a2.Time then a2 = a1 end
  10764.                 local b1 = NumberSequenceKeypoint.new(1-val,0)
  10765.                 local b2 = NumberSequenceKeypoint.new(math.max(0.5,1-val-math.min(0.05,val)),1)
  10766.                 if b1.Time == b2.Time then b2 = b1 end
  10767.                 local goal = NumberSequenceKeypoint.new(1,0)
  10768.                 backGradient.Transparency = NumberSequence.new({start,a1,a2,b2,b1,goal})
  10769.                 outlinesGradient.Transparency = NumberSequence.new({start,a1,a2,b2,b1,goal})
  10770.         end)
  10771.        
  10772.         fastwait(0.4)
  10773.        
  10774.         tweenNumber(100,ti,function(val)
  10775.             val = val/166.66
  10776.             local start = NumberSequenceKeypoint.new(0,0)
  10777.             local a1 = NumberSequenceKeypoint.new(val,0)
  10778.             local a2 = NumberSequenceKeypoint.new(val+0.01,1)
  10779.             local goal = NumberSequenceKeypoint.new(1,1)
  10780.             holderGradient.Transparency = NumberSequence.new({start,a1,a2,goal})
  10781.         end)
  10782.        
  10783.         tweenS:Create(titleText,ti,{Position = UDim2.new(0,60,0,15), TextTransparency = 0}):Play()
  10784.         tweenS:Create(descText,ti,{Position = UDim2.new(0,20,0,60), TextTransparency = 0}):Play()
  10785.        
  10786.         local function rightTextTransparency(obj)
  10787.             tweenNumber(100,ti,function(val)
  10788.                 val = val/100
  10789.                 local a1 = NumberSequenceKeypoint.new(1-val,0)
  10790.                 local a2 = NumberSequenceKeypoint.new(math.max(0,1-val-0.01),1)
  10791.                 if a1.Time == a2.Time then a2 = a1 end
  10792.                 local start = NumberSequenceKeypoint.new(0,a1 == a2 and 0 or 1)
  10793.                 local goal = NumberSequenceKeypoint.new(1,0)
  10794.                 obj.Transparency = NumberSequence.new({start,a2,a1,goal})
  10795.             end)
  10796.         end
  10797.         rightTextTransparency(versionGradient)
  10798.         rightTextTransparency(creatorGradient)
  10799.        
  10800.         fastwait(0.9)
  10801.        
  10802.         local progressTI = TweenInfo.new(0.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
  10803.        
  10804.         tweenS:Create(statusText,progressTI,{Position = UDim2.new(0,20,0,120), TextTransparency = 0}):Play()
  10805.         tweenS:Create(progressBar,progressTI,{Position = UDim2.new(0,60,0,145), Size = UDim2.new(0,100,0,4)}):Play()
  10806.        
  10807.         fastwait(0.25)
  10808.        
  10809.         local function setProgress(text,n)
  10810.             statusText.Text = text
  10811.             tweenS:Create(progressBar.Bar,progressTI,{Size = UDim2.new(n,0,1,0)}):Play()
  10812.         end
  10813.        
  10814.         local function close()
  10815.             tweenS:Create(titleText,progressTI,{TextTransparency = 1}):Play()
  10816.             tweenS:Create(descText,progressTI,{TextTransparency = 1}):Play()
  10817.             tweenS:Create(versionText,progressTI,{TextTransparency = 1}):Play()
  10818.             tweenS:Create(creatorText,progressTI,{TextTransparency = 1}):Play()
  10819.             tweenS:Create(statusText,progressTI,{TextTransparency = 1}):Play()
  10820.             tweenS:Create(progressBar,progressTI,{BackgroundTransparency = 1}):Play()
  10821.             tweenS:Create(progressBar.Bar,progressTI,{BackgroundTransparency = 1}):Play()
  10822.             tweenS:Create(progressBar.ImageLabel,progressTI,{ImageTransparency = 1}):Play()
  10823.            
  10824.             tweenNumber(100,TweenInfo.new(0.4,Enum.EasingStyle.Back,Enum.EasingDirection.In),function(val)
  10825.                 val = val/250
  10826.                 local start = NumberSequenceKeypoint.new(0,0)
  10827.                 local a1 = NumberSequenceKeypoint.new(0.6+val,0)
  10828.                 local a2 = NumberSequenceKeypoint.new(math.min(1,0.601+val),1)
  10829.                 if a1.Time == a2.Time then a2 = a1 end
  10830.                 local goal = NumberSequenceKeypoint.new(1,a1 == a2 and 0 or 1)
  10831.                 holderGradient.Transparency = NumberSequence.new({start,a1,a2,goal})
  10832.             end)
  10833.            
  10834.             fastwait(0.5)
  10835.             gui.Main.BackgroundTransparency = 1
  10836.             outlinesGradient.Rotation = 30
  10837.            
  10838.             tweenNumber(100,ti,function(val)
  10839.                 val = val/100
  10840.                 local start = NumberSequenceKeypoint.new(0,1)
  10841.                 local a1 = NumberSequenceKeypoint.new(val,1)
  10842.                 local a2 = NumberSequenceKeypoint.new(math.min(1,val+math.min(0.05,val)),0)
  10843.                 if a1.Time == a2.Time then a2 = a1 end
  10844.                 local goal = NumberSequenceKeypoint.new(1,a1 == a2 and 1 or 0)
  10845.                 outlinesGradient.Transparency = NumberSequence.new({start,a1,a2,goal})
  10846.                 holderGradient.Transparency = NumberSequence.new({start,a1,a2,goal})
  10847.             end)
  10848.            
  10849.             fastwait(0.45)
  10850.             gui:Destroy()
  10851.         end
  10852.        
  10853.         return {SetProgress = setProgress, Close = close}
  10854.     end
  10855.    
  10856.     Main.CreateApp = function(data)
  10857.         if Main.MenuApps[data.Name] then return end -- TODO: Handle conflict
  10858.         local control = {}
  10859.        
  10860.         local app = Main.AppTemplate:Clone()
  10861.        
  10862.         local iconIndex = data.Icon
  10863.         if data.IconMap and iconIndex then
  10864.             if type(iconIndex) == "number" then
  10865.                 data.IconMap:Display(app.Main.Icon,iconIndex)
  10866.             elseif type(iconIndex) == "string" then
  10867.                 data.IconMap:DisplayByKey(app.Main.Icon,iconIndex)
  10868.             end
  10869.         elseif type(iconIndex) == "string" then
  10870.             app.Main.Icon.Image = iconIndex
  10871.         else
  10872.             app.Main.Icon.Image = ""
  10873.         end
  10874.        
  10875.         local function updateState()
  10876.             app.Main.BackgroundTransparency = data.Open and 0 or (Lib.CheckMouseInGui(app.Main) and 0 or 1)
  10877.             app.Main.Highlight.Visible = data.Open
  10878.         end
  10879.        
  10880.         local function enable(silent)
  10881.             if data.Open then return end
  10882.             data.Open = true
  10883.             updateState()
  10884.             if not silent then
  10885.                 if data.Window then data.Window:Show() end
  10886.                 if data.OnClick then data.OnClick(data.Open) end
  10887.             end
  10888.         end
  10889.        
  10890.         local function disable(silent)
  10891.             if not data.Open then return end
  10892.             data.Open = false
  10893.             updateState()
  10894.             if not silent then
  10895.                 if data.Window then data.Window:Hide() end
  10896.                 if data.OnClick then data.OnClick(data.Open) end
  10897.             end
  10898.         end
  10899.        
  10900.         updateState()
  10901.        
  10902.         local ySize = service.TextService:GetTextSize(data.Name,14,Enum.Font.SourceSans,Vector2.new(62,999999)).Y
  10903.         app.Main.Size = UDim2.new(1,0,0,math.clamp(46+ySize,60,74))
  10904.         app.Main.AppName.Text = data.Name
  10905.        
  10906.         app.Main.InputBegan:Connect(function(input)
  10907.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  10908.                 app.Main.BackgroundTransparency = 0
  10909.                 app.Main.BackgroundColor3 = Settings.Theme.ButtonHover
  10910.             end
  10911.         end)
  10912.        
  10913.         app.Main.InputEnded:Connect(function(input)
  10914.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  10915.                 app.Main.BackgroundTransparency = data.Open and 0 or 1
  10916.                 app.Main.BackgroundColor3 = Settings.Theme.Button
  10917.             end
  10918.         end)
  10919.        
  10920.         app.Main.MouseButton1Click:Connect(function()
  10921.             if data.Open then disable() else enable() end
  10922.         end)
  10923.        
  10924.         local window = data.Window
  10925.         if window then
  10926.             window.OnActivate:Connect(function() enable(true) end)
  10927.             window.OnDeactivate:Connect(function() disable(true) end)
  10928.         end
  10929.        
  10930.         app.Visible = true
  10931.         app.Parent = Main.AppsContainer
  10932.         Main.AppsFrame.CanvasSize = UDim2.new(0,0,0,Main.AppsContainerGrid.AbsoluteCellCount.Y*82 + 8)
  10933.        
  10934.         control.Enable = enable
  10935.         control.Disable = disable
  10936.         Main.MenuApps[data.Name] = control
  10937.         return control
  10938.     end
  10939.    
  10940.     Main.SetMainGuiOpen = function(val)
  10941.         Main.MainGuiOpen = val
  10942.        
  10943.         Main.MainGui.OpenButton.Text = val and "X" or "Dex"
  10944.         if val then Main.MainGui.OpenButton.MainFrame.Visible = true end
  10945.         Main.MainGui.OpenButton.MainFrame:TweenSize(val and UDim2.new(0,224,0,200) or UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,0.2,true)
  10946.         --Main.MainGui.OpenButton.BackgroundTransparency = val and 0 or (Lib.CheckMouseInGui(Main.MainGui.OpenButton) and 0 or 0.2)
  10947.         service.TweenService:Create(Main.MainGui.OpenButton,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = val and 0 or (Lib.CheckMouseInGui(Main.MainGui.OpenButton) and 0 or 0.2)}):Play()
  10948.        
  10949.         if Main.MainGuiMouseEvent then Main.MainGuiMouseEvent:Disconnect() end
  10950.        
  10951.         if not val then
  10952.             local startTime = tick()
  10953.             Main.MainGuiCloseTime = startTime
  10954.             coroutine.wrap(function()
  10955.                 Lib.FastWait(0.2)
  10956.                 if not Main.MainGuiOpen and startTime == Main.MainGuiCloseTime then Main.MainGui.OpenButton.MainFrame.Visible = false end
  10957.             end)()
  10958.         else
  10959.             Main.MainGuiMouseEvent = service.UserInputService.InputBegan:Connect(function(input)
  10960.                 if input.UserInputType == Enum.UserInputType.MouseButton1 and not Lib.CheckMouseInGui(Main.MainGui.OpenButton) and not Lib.CheckMouseInGui(Main.MainGui.OpenButton.MainFrame) then
  10961.                     Main.SetMainGuiOpen(false)
  10962.                 end
  10963.             end)
  10964.         end
  10965.     end
  10966.    
  10967.     Main.CreateMainGui = function()
  10968.         local gui = create({
  10969.             {1,"ScreenGui",{IgnoreGuiInset=true,Name="MainMenu",}},
  10970.             {2,"TextButton",{AnchorPoint=Vector2.new(0.5,0),AutoButtonColor=false,BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),BorderSizePixel=0,Font=4,Name="OpenButton",Parent={1},Position=UDim2.new(0.5,0,0,2),Size=UDim2.new(0,32,0,32),Text="Dex",TextColor3=Color3.new(1,1,1),TextSize=16,TextTransparency=0.20000000298023,}},
  10971.             {3,"UICorner",{CornerRadius=UDim.new(0,4),Parent={2},}},
  10972.             {4,"Frame",{AnchorPoint=Vector2.new(0.5,0),BackgroundColor3=Color3.new(0.17647059261799,0.17647059261799,0.17647059261799),ClipsDescendants=true,Name="MainFrame",Parent={2},Position=UDim2.new(0.5,0,1,-4),Size=UDim2.new(0,224,0,200),}},
  10973.             {5,"UICorner",{CornerRadius=UDim.new(0,4),Parent={4},}},
  10974.             {6,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),Name="BottomFrame",Parent={4},Position=UDim2.new(0,0,1,-24),Size=UDim2.new(1,0,0,24),}},
  10975.             {7,"UICorner",{CornerRadius=UDim.new(0,4),Parent={6},}},
  10976.             {8,"Frame",{BackgroundColor3=Color3.new(0.20392157137394,0.20392157137394,0.20392157137394),BorderSizePixel=0,Name="CoverFrame",Parent={6},Size=UDim2.new(1,0,0,4),}},
  10977.             {9,"Frame",{BackgroundColor3=Color3.new(0.1294117718935,0.1294117718935,0.1294117718935),BorderSizePixel=0,Name="Line",Parent={8},Position=UDim2.new(0,0,0,-1),Size=UDim2.new(1,0,0,1),}},
  10978.             {10,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Settings",Parent={6},Position=UDim2.new(1,-48,0,0),Size=UDim2.new(0,24,1,0),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  10979.             {11,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://6578871732",ImageTransparency=0.20000000298023,Name="Icon",Parent={10},Position=UDim2.new(0,4,0,4),Size=UDim2.new(0,16,0,16),}},
  10980.             {12,"TextButton",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Font=3,Name="Information",Parent={6},Position=UDim2.new(1,-24,0,0),Size=UDim2.new(0,24,1,0),Text="",TextColor3=Color3.new(1,1,1),TextSize=14,}},
  10981.             {13,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://6578933307",ImageTransparency=0.20000000298023,Name="Icon",Parent={12},Position=UDim2.new(0,4,0,4),Size=UDim2.new(0,16,0,16),}},
  10982.             {14,"ScrollingFrame",{Active=true,AnchorPoint=Vector2.new(0.5,0),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderColor3=Color3.new(0.1294117718935,0.1294117718935,0.1294117718935),BorderSizePixel=0,Name="AppsFrame",Parent={4},Position=UDim2.new(0.5,0,0,0),ScrollBarImageColor3=Color3.new(0,0,0),ScrollBarThickness=4,Size=UDim2.new(0,222,1,-25),}},
  10983.             {15,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="Container",Parent={14},Position=UDim2.new(0,7,0,8),Size=UDim2.new(1,-14,0,2),}},
  10984.             {16,"UIGridLayout",{CellSize=UDim2.new(0,66,0,74),Parent={15},SortOrder=2,}},
  10985.             {17,"Frame",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Name="App",Parent={1},Size=UDim2.new(0,100,0,100),Visible=false,}},
  10986.             {18,"TextButton",{AutoButtonColor=false,BackgroundColor3=Color3.new(0.2352941185236,0.2352941185236,0.2352941185236),BorderSizePixel=0,Font=3,Name="Main",Parent={17},Size=UDim2.new(1,0,0,60),Text="",TextColor3=Color3.new(0,0,0),TextSize=14,}},
  10987.             {19,"ImageLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,Image="rbxassetid://6579106223",ImageRectSize=Vector2.new(32,32),Name="Icon",Parent={18},Position=UDim2.new(0.5,-16,0,4),ScaleType=4,Size=UDim2.new(0,32,0,32),}},
  10988.             {20,"TextLabel",{BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderSizePixel=0,Font=3,Name="AppName",Parent={18},Position=UDim2.new(0,2,0,38),Size=UDim2.new(1,-4,1,-40),Text="Explorer",TextColor3=Color3.new(1,1,1),TextSize=14,TextTransparency=0.10000000149012,TextTruncate=1,TextWrapped=true,TextYAlignment=0,}},
  10989.             {21,"Frame",{BackgroundColor3=Color3.new(0,0.66666668653488,1),BorderSizePixel=0,Name="Highlight",Parent={18},Position=UDim2.new(0,0,1,-2),Size=UDim2.new(1,0,0,2),}},
  10990.         })
  10991.         Main.MainGui = gui
  10992.         Main.AppsFrame = gui.OpenButton.MainFrame.AppsFrame
  10993.         Main.AppsContainer = Main.AppsFrame.Container
  10994.         Main.AppsContainerGrid = Main.AppsContainer.UIGridLayout
  10995.         Main.AppTemplate = gui.App
  10996.         Main.MainGuiOpen = false
  10997.        
  10998.         local openButton = gui.OpenButton
  10999.         openButton.BackgroundTransparency = 0.2
  11000.         openButton.MainFrame.Size = UDim2.new(0,0,0,0)
  11001.         openButton.MainFrame.Visible = false
  11002.         openButton.MouseButton1Click:Connect(function()
  11003.             Main.SetMainGuiOpen(not Main.MainGuiOpen)
  11004.         end)
  11005.        
  11006.         openButton.InputBegan:Connect(function(input)
  11007.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  11008.                 service.TweenService:Create(Main.MainGui.OpenButton,TweenInfo.new(0,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
  11009.             end
  11010.         end)
  11011.  
  11012.         openButton.InputEnded:Connect(function(input)
  11013.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  11014.                 service.TweenService:Create(Main.MainGui.OpenButton,TweenInfo.new(0,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = Main.MainGuiOpen and 0 or 0.2}):Play()
  11015.             end
  11016.         end)
  11017.        
  11018.         -- Create Main Apps
  11019.         Main.CreateApp({Name = "Explorer", IconMap = Main.LargeIcons, Icon = "Explorer", Open = true, Window = Explorer.Window})
  11020.        
  11021.         Main.CreateApp({Name = "Properties", IconMap = Main.LargeIcons, Icon = "Properties", Open = true, Window = Properties.Window})
  11022.        
  11023.         Main.CreateApp({Name = "Script Viewer", IconMap = Main.LargeIcons, Icon = "Script_Viewer", Window = ScriptViewer.Window})
  11024.  
  11025.         local cptsOnMouseClick = nil
  11026.         Main.CreateApp({Name = "Click part to select", IconMap = Main.LargeIcons, Icon = 6, OnClick = function(callback)
  11027.             if callback then
  11028.                 local mouse = Main.Mouse
  11029.                 cptsOnMouseClick = mouse.Button1Down:Connect(function()
  11030.                     pcall(function()
  11031.                         local object = mouse.Target
  11032.                         if nodes[object] then
  11033.                             selection:Set(nodes[object])
  11034.                             Explorer.ViewNode(nodes[object])
  11035.                         end
  11036.                     end)
  11037.                 end)
  11038.             else if cptsOnMouseClick ~= nil then cptsOnMouseClick:Disconnect() cptsOnMouseClick = nil end end
  11039.         end})
  11040.        
  11041.         Lib.ShowGui(gui)
  11042.     end
  11043.    
  11044.     Main.SetupFilesystem = function()
  11045.         if not env.writefile or not env.makefolder then return end
  11046.         local writefile, makefolder = env.writefile, env.makefolder
  11047.         makefolder("dex")
  11048.         makefolder("dex/assets")
  11049.         makefolder("dex/saved")
  11050.         makefolder("dex/plugins")
  11051.         makefolder("dex/ModuleCache")
  11052.     end
  11053.    
  11054.     Main.LocalDepsUpToDate = function()
  11055.         return Main.DepsVersionData and Main.ClientVersion == Main.DepsVersionData[1]
  11056.     end
  11057.    
  11058.     Main.Init = function()
  11059.         Main.Elevated = pcall(function() local a = cloneref(game["Run Service"].Parent:GetService("CoreGui")):GetFullName() end)
  11060.         Main.InitEnv()
  11061.         Main.LoadSettings()
  11062.         Main.SetupFilesystem()
  11063.        
  11064.         -- Load Lib
  11065.         local intro = Main.CreateIntro("Initializing Library")
  11066.         Lib = Main.LoadModule("Lib")
  11067.         Lib.FastWait()
  11068.        
  11069.         -- Init other stuff
  11070.         --Main.IncompatibleTest()
  11071.        
  11072.         -- Init icons
  11073.         Main.MiscIcons = Lib.IconMap.new("rbxassetid://6511490623",256,256,16,16)
  11074.         Main.MiscIcons:SetDict({
  11075.             Reference = 0,             Cut = 1,                         Cut_Disabled = 2,      Copy = 3,               Copy_Disabled = 4,    Paste = 5,                Paste_Disabled = 6,
  11076.             Delete = 7,                Delete_Disabled = 8,             Group = 9,             Group_Disabled = 10,    Ungroup = 11,         Ungroup_Disabled = 12,    TeleportTo = 13,
  11077.             Rename = 14,               JumpToParent = 15,               ExploreData = 16,      Save = 17,              CallFunction = 18,    CallRemote = 19,          Undo = 20,
  11078.             Undo_Disabled = 21,        Redo = 22,                       Redo_Disabled = 23,    Expand_Over = 24,       Expand = 25,          Collapse_Over = 26,       Collapse = 27,
  11079.             SelectChildren = 28,       SelectChildren_Disabled = 29,    InsertObject = 30,     ViewScript = 31,        AddStar = 32,         RemoveStar = 33,          Script_Disabled = 34,
  11080.             LocalScript_Disabled = 35, Play = 36,                       Pause = 37,            Rename_Disabled = 38
  11081.         })
  11082.         Main.LargeIcons = Lib.IconMap.new("rbxassetid://6579106223",256,256,32,32)
  11083.         Main.LargeIcons:SetDict({
  11084.             Explorer = 0, Properties = 1, Script_Viewer = 2,
  11085.         })
  11086.        
  11087.         -- Fetch version if needed
  11088.         intro.SetProgress("Fetching Roblox Version",0.2)
  11089.         if Main.Elevated then
  11090.             local fileVer = Lib.ReadFile("dex/deps_version.dat")
  11091.             Main.ClientVersion = Version()
  11092.             if fileVer then
  11093.                 Main.DepsVersionData = string.split(fileVer,"\n")
  11094.                 if Main.LocalDepsUpToDate() then
  11095.                     Main.RobloxVersion = Main.DepsVersionData[2]
  11096.                 end
  11097.             end
  11098.             Main.RobloxVersion = Main.RobloxVersion or game:HttpGet("http://setup.roblox.com/versionQTStudio")
  11099.         end
  11100.        
  11101.         -- Fetch external deps
  11102.         intro.SetProgress("Fetching API",0.35)
  11103.         API = Main.FetchAPI()
  11104.         Lib.FastWait()
  11105.         intro.SetProgress("Fetching RMD",0.5)
  11106.         RMD = Main.FetchRMD()
  11107.         Lib.FastWait()
  11108.        
  11109.         -- Save external deps locally if needed
  11110.         if Main.Elevated and env.writefile and not Main.LocalDepsUpToDate() then
  11111.             env.writefile("dex/deps_version.dat",Main.ClientVersion.."\n"..Main.RobloxVersion)
  11112.             env.writefile("dex/rbx_api.dat",Main.RawAPI)
  11113.             env.writefile("dex/rbx_rmd.dat",Main.RawRMD)
  11114.         end
  11115.        
  11116.         -- Load other modules
  11117.         intro.SetProgress("Loading Modules",0.75)
  11118.         Main.AppControls.Lib.InitDeps(Main.GetInitDeps()) -- Missing deps now available
  11119.         Main.LoadModules()
  11120.         Lib.FastWait()
  11121.        
  11122.         -- Init other modules
  11123.         intro.SetProgress("Initializing Modules",0.9)
  11124.         Explorer.Init()
  11125.         Properties.Init()
  11126.         ScriptViewer.Init()
  11127.         Lib.FastWait()
  11128.        
  11129.         -- Done
  11130.         intro.SetProgress("Complete",1)
  11131.         coroutine.wrap(function()
  11132.             Lib.FastWait(1.25)
  11133.             intro.Close()
  11134.         end)()
  11135.        
  11136.         -- Init window system, create main menu, show explorer and properties
  11137.         Lib.Window.Init()
  11138.         Main.CreateMainGui()
  11139.         Explorer.Window:Show({Align = "right", Pos = 1, Size = 0.5, Silent = true})
  11140.         Properties.Window:Show({Align = "right", Pos = 2, Size = 0.5, Silent = true})
  11141.         Lib.DeferFunc(function() Lib.Window.ToggleSide("right") end)
  11142.     end
  11143.    
  11144.     return Main
  11145. end)()
  11146.  
  11147. -- Start
  11148. Main.Init()
Add Comment
Please, Sign In to add comment