Advertisement
memberhero

huh

May 11th, 2018
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.33 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. ScreenGui0 = Instance.new("ScreenGui")
  20. Frame1 = Instance.new("Frame")
  21. LocalScript2 = Instance.new("LocalScript")
  22. BindableEvent3 = Instance.new("BindableEvent")
  23. BindableFunction4 = Instance.new("BindableFunction")
  24. BindableFunction5 = Instance.new("BindableFunction")
  25. BindableFunction6 = Instance.new("BindableFunction")
  26. BindableFunction7 = Instance.new("BindableFunction")
  27. ScreenGui0.Parent = mas
  28. Frame1.Name = "ExplorerPanel"
  29. Frame1.Parent = ScreenGui0
  30. Frame1.Transparency = 0.10000000149012
  31. Frame1.Size = UDim2.new(0, 300, 1, -168)
  32. Frame1.Position = UDim2.new(1, -308, 0, 160)
  33. Frame1.BackgroundColor3 = Color3.new(1, 1, 1)
  34. Frame1.BackgroundTransparency = 0.10000000149012
  35. Frame1.BorderColor3 = Color3.new(0.74902, 0.74902, 0.74902)
  36. LocalScript2.Parent = Frame1
  37. table.insert(cors,sandbox(LocalScript2,function()
  38. -- initial states
  39. local Option = {
  40. -- can modify objects
  41. Modifiable = true;
  42. -- can select objects
  43. Selectable = true;
  44. }
  45.  
  46. -- general size of GUI objects, in pixels
  47. local GUI_SIZE = 16
  48. -- padding between items within each entry
  49. local ENTRY_PADDING = 1
  50. -- padding between each entry
  51. local ENTRY_MARGIN = 1
  52.  
  53. --[[
  54.  
  55. # Explorer Panel
  56.  
  57. A GUI panel that displays the game hierarchy.
  58.  
  59.  
  60. ## Selection Bindables
  61.  
  62. - `Function GetSelection ( )`
  63.  
  64. Returns an array of objects representing the objects currently
  65. selected in the panel.
  66.  
  67. - `Function SetSelection ( Objects selection )`
  68.  
  69. Sets the objects that are selected in the panel. `selection` is an array
  70. of objects.
  71.  
  72. - `Event SelectionChanged ( )`
  73.  
  74. Fired after the selection changes.
  75.  
  76.  
  77. ## Option Bindables
  78.  
  79. - `Function GetOption ( string optionName )`
  80.  
  81. If `optionName` is given, returns the value of that option. Otherwise,
  82. returns a table of options and their current values.
  83.  
  84. - `Function SetOption ( string optionName, bool value )`
  85.  
  86. Sets `optionName` to `value`.
  87.  
  88. Options:
  89.  
  90. - Modifiable
  91.  
  92. Whether objects can be modified by the panel.
  93.  
  94. Note that modifying objects depends on being able to select them. If
  95. Selectable is false, then Actions will not be available. Reparenting
  96. is still possible, but only for the dragged object.
  97.  
  98. - Selectable
  99.  
  100. Whether objects can be selected.
  101.  
  102. If Modifiable is false, then left-clicking will perform a drag
  103. selection.
  104.  
  105. ## Updates
  106.  
  107. - 2013-09-18
  108. - Fixed explorer icons to match studio explorer.
  109.  
  110. - 2013-09-14
  111. - Added GetOption and SetOption bindables.
  112. - Option: Modifiable; sets whether objects can be modified by the panel.
  113. - Option: Selectable; sets whether objects can be selected.
  114. - Slight modification to left-click selection behavior.
  115. - Improved layout and scaling.
  116.  
  117. - 2013-09-13
  118. - Added drag to reparent objects.
  119. - Left-click to select/deselect object.
  120. - Left-click and drag unselected object to reparent single object.
  121. - Left-click and drag selected object to move reparent entire selection.
  122. - Right-click while dragging to cancel.
  123.  
  124. - 2013-09-11
  125. - Added explorer panel header with actions.
  126. - Added Cut action.
  127. - Added Copy action.
  128. - Added Paste action.
  129. - Added Delete action.
  130. - Added drag selection.
  131. - Left-click: Add to selection on drag.
  132. - Right-click: Add to or remove from selection on drag.
  133. - Ensured SelectionChanged fires only when the selection actually changes.
  134. - Added documentation and change log.
  135. - Fixed thread issue.
  136.  
  137. - 2013-09-09
  138. - Added basic multi-selection.
  139. - Left-click to set selection.
  140. - Right-click to add to or remove from selection.
  141. - Removed "Selection" ObjectValue.
  142. - Added GetSelection BindableFunction.
  143. - Added SetSelection BindableFunction.
  144. - Added SelectionChanged BindableEvent.
  145. - Changed font to SourceSans.
  146.  
  147. - 2013-08-31
  148. - Improved GUI sizing based off of `GUI_SIZE` constant.
  149. - Automatic font size detection.
  150.  
  151. - 2013-08-27
  152. - Initial explorer panel.
  153.  
  154.  
  155. ## Todo
  156.  
  157. - Sorting
  158. - by ExplorerOrder
  159. - by children
  160. - by name
  161. - Drag objects to reparent
  162.  
  163. ]]
  164.  
  165. local ENTRY_SIZE = GUI_SIZE + ENTRY_PADDING*2
  166. local ENTRY_BOUND = ENTRY_SIZE + ENTRY_MARGIN
  167. local HEADER_SIZE = ENTRY_SIZE
  168.  
  169. local FONT = 'SourceSans'
  170. local FONT_SIZE do
  171. local size = {8,9,10,11,12,14,18,24,36,48}
  172. local s
  173. local n = math.huge
  174. for i = 1,#size do
  175. if size[i] <= GUI_SIZE then
  176. FONT_SIZE = i - 1
  177. end
  178. end
  179. end
  180.  
  181. local GuiColor = {
  182. Background = Color3.new(233/255, 233/255, 233/255);
  183. Border = Color3.new(149/255, 149/255, 149/255);
  184. Selected = Color3.new( 96/255, 140/255, 211/255);
  185. BorderSelected = Color3.new( 86/255, 125/255, 188/255);
  186. Text = Color3.new( 0/255, 0/255, 0/255);
  187. TextDisabled = Color3.new(128/255, 128/255, 128/255);
  188. TextSelected = Color3.new(255/255, 255/255, 255/255);
  189. Button = Color3.new(221/255, 221/255, 221/255);
  190. ButtonBorder = Color3.new(149/255, 149/255, 149/255);
  191. ButtonSelected = Color3.new(255/255, 0/255, 0/255);
  192. Field = Color3.new(255/255, 255/255, 255/255);
  193. FieldBorder = Color3.new(191/255, 191/255, 191/255);
  194. TitleBackground = Color3.new(178/255, 178/255, 178/255);
  195. }
  196.  
  197. ----------------------------------------------------------------
  198. ----------------------------------------------------------------
  199. ----------------------------------------------------------------
  200. ----------------------------------------------------------------
  201. ---- Icon map constants
  202.  
  203. local MAP_ID = 129293660
  204.  
  205. -- Indices based on implementation of Icon function.
  206. local ACTION_CUT = 160
  207. local ACTION_COPY = 161
  208. local ACTION_PASTE = 162
  209. local ACTION_DELETE = 163
  210. local ACTION_SORT = 164
  211. local ACTION_CUT_OVER = 174
  212. local ACTION_COPY_OVER = 175
  213. local ACTION_PASTE_OVER = 176
  214. local ACTION_DELETE_OVER = 177
  215. local ACTION_SORT_OVER = 178
  216.  
  217. local NODE_COLLAPSED = 165
  218. local NODE_EXPANDED = 166
  219. local NODE_COLLAPSED_OVER = 179
  220. local NODE_EXPANDED_OVER = 180
  221.  
  222. local ExplorerIndex = {
  223. ["Accoutrement"] = 32;
  224. ["Animation"] = 60;
  225. ["AnimationTrack"] = 60;
  226. ["ArcHandles"] = 56;
  227. ["Backpack"] = 20;
  228. ["BillboardGui"] = 64;
  229. ["BindableEvent"] = 67;
  230. ["BindableFunction"] = 66;
  231. ["BlockMesh"] = 8;
  232. ["BodyAngularVelocity"] = 14;
  233. ["BodyForce"] = 14;
  234. ["BodyGyro"] = 14;
  235. ["BodyPosition"] = 14;
  236. ["BodyThrust"] = 14;
  237. ["BodyVelocity"] = 14;
  238. ["BoolValue"] = 4;
  239. ["BrickColorValue"] = 4;
  240. ["Camera"] = 5;
  241. ["CFrameValue"] = 4;
  242. ["CharacterMesh"] = 60;
  243. ["ClickDetector"] = 41;
  244. ["Color3Value"] = 4;
  245. ["Configuration"] = 58;
  246. ["CoreGui"] = 46;
  247. ["CornerWedgePart"] = 1;
  248. ["CustomEvent"] = 4;
  249. ["CustomEventReceiver"] = 4;
  250. ["CylinderMesh"] = 8;
  251. ["Debris"] = 30;
  252. ["Decal"] = 7;
  253. ["Dialog"] = 62;
  254. ["DialogChoice"] = 63;
  255. ["DoubleConstrainedValue"] = 4;
  256. ["Explosion"] = 36;
  257. ["Fire"] = 61;
  258. ["Flag"] = 38;
  259. ["FlagStand"] = 39;
  260. ["FloorWire"] = 4;
  261. ["ForceField"] = 37;
  262. ["Frame"] = 48;
  263. ["GuiButton"] = 52;
  264. ["GuiMain"] = 47;
  265. ["Handles"] = 53;
  266. ["Hat"] = 45;
  267. ["Hint"] = 33;
  268. ["HopperBin"] = 22;
  269. ["Humanoid"] = 9;
  270. ["ImageButton"] = 52;
  271. ["ImageLabel"] = 49;
  272. ["IntConstrainedValue"] = 4;
  273. ["IntValue"] = 4;
  274. ["JointInstance"] = 34;
  275. ["Keyframe"] = 60;
  276. ["Lighting"] = 13;
  277. ["LocalScript"] = 18;
  278. ["MarketplaceService"] = 46;
  279. ["Message"] = 33;
  280. ["Model"] = 2;
  281. ["NetworkClient"] = 16;
  282. ["NetworkReplicator"] = 29;
  283. ["NetworkServer"] = 15;
  284. ["NumberValue"] = 4;
  285. ["ObjectValue"] = 4;
  286. ["Pants"] = 44;
  287. ["ParallelRampPart"] = 1;
  288. ["Part"] = 1;
  289. ["PartPairLasso"] = 57;
  290. ["Platform"] = 35;
  291. ["Player"] = 12;
  292. ["PlayerGui"] = 46;
  293. ["Players"] = 21;
  294. ["PointLight"] = 13;
  295. ["Pose"] = 60;
  296. ["PrismPart"] = 1;
  297. ["PyramidPart"] = 1;
  298. ["RayValue"] = 4;
  299. ["ReplicatedStorage"] = 0;
  300. ["RightAngleRampPart"] = 1;
  301. ["RocketPropulsion"] = 14;
  302. ["ScreenGui"] = 47;
  303. ["Script"] = 6;
  304. ["Seat"] = 35;
  305. ["SelectionBox"] = 54;
  306. ["SelectionPartLasso"] = 57;
  307. ["SelectionPointLasso"] = 57;
  308. ["ServerScriptService"] = 0;
  309. ["ServerStorage"] = 0;
  310. ["Shirt"] = 43;
  311. ["ShirtGraphic"] = 40;
  312. ["SkateboardPlatform"] = 35;
  313. ["Sky"] = 28;
  314. ["Smoke"] = 59;
  315. ["Sound"] = 11;
  316. ["SoundService"] = 31;
  317. ["Sparkles"] = 42;
  318. ["SpawnLocation"] = 25;
  319. ["SpecialMesh"] = 8;
  320. ["SpotLight"] = 13;
  321. ["StarterGear"] = 20;
  322. ["StarterGui"] = 46;
  323. ["StarterPack"] = 20;
  324. ["Status"] = 2;
  325. ["StringValue"] = 4;
  326. ["SurfaceSelection"] = 55;
  327. ["Team"] = 24;
  328. ["Teams"] = 23;
  329. ["Terrain"] = 65;
  330. ["TestService"] = 68;
  331. ["TextBox"] = 51;
  332. ["TextButton"] = 51;
  333. ["TextLabel"] = 50;
  334. ["Texture"] = 10;
  335. ["TextureTrail"] = 4;
  336. ["Tool"] = 17;
  337. ["TouchTransmitter"] = 37;
  338. ["TrussPart"] = 1;
  339. ["Vector3Value"] = 4;
  340. ["VehicleSeat"] = 35;
  341. ["WedgePart"] = 1;
  342. ["Weld"] = 34;
  343. ["Workspace"] = 19;
  344. }
  345.  
  346. ----------------------------------------------------------------
  347. ----------------------------------------------------------------
  348. ----------------------------------------------------------------
  349. ----------------------------------------------------------------
  350. ----------------------------------------------------------------
  351.  
  352. function Create(ty,data)
  353. local obj
  354. if type(ty) == 'string' then
  355. obj = Instance.new(ty)
  356. else
  357. obj = ty
  358. end
  359. for k, v in pairs(data) do
  360. if type(k) == 'number' then
  361. v.Parent = obj
  362. else
  363. obj[k] = v
  364. end
  365. end
  366. return obj
  367. end
  368.  
  369. -- Connects a function to an event such that it fires asynchronously
  370. function Connect(event,func)
  371. return event:connect(function(...)
  372. local a = {...}
  373. Spawn(function() func(unpack(a)) end)
  374. end)
  375. end
  376.  
  377. -- returns the ascendant ScreenGui of an object
  378. function GetScreen(screen)
  379. if screen == nil then return nil end
  380. while not screen:IsA("ScreenGui") do
  381. screen = screen.Parent
  382. if screen == nil then return nil end
  383. end
  384. return screen
  385. end
  386.  
  387. do
  388. local ZIndexLock = {}
  389. -- Sets the ZIndex of an object and its descendants. Objects are locked so
  390. -- that SetZIndexOnChanged doesn't spawn multiple threads that set the
  391. -- ZIndex of the same object.
  392. function SetZIndex(object,z)
  393. if not ZIndexLock[object] then
  394. ZIndexLock[object] = true
  395. if object:IsA'GuiObject' then
  396. object.ZIndex = z
  397. end
  398. local children = object:GetChildren()
  399. for i = 1,#children do
  400. SetZIndex(children[i],z)
  401. end
  402. ZIndexLock[object] = nil
  403. end
  404. end
  405.  
  406. function SetZIndexOnChanged(object)
  407. return object.Changed:connect(function(p)
  408. if p == "ZIndex" then
  409. SetZIndex(object,object.ZIndex)
  410. end
  411. end)
  412. end
  413. end
  414.  
  415. ---- IconMap ----
  416. -- Image size: 256px x 256px
  417. -- Icon size: 16px x 16px
  418. -- Padding between each icon: 2px
  419. -- Padding around image edge: 1px
  420. -- Total icons: 14 x 14 (196)
  421. local Icon do
  422. local iconMap = 'http://www.roblox.com/asset/?id=' .. MAP_ID
  423. Game:GetService('ContentProvider'):Preload(iconMap)
  424. local iconDehash do
  425. -- 14 x 14, 0-based input, 0-based output
  426. local f=math.floor
  427. function iconDehash(h)
  428. return f(h/14%14),f(h%14)
  429. end
  430. end
  431.  
  432. function Icon(IconFrame,index)
  433. local row,col = iconDehash(index)
  434. local mapSize = Vector2.new(256,256)
  435. local pad,border = 2,1
  436. local iconSize = 16
  437.  
  438. local class = 'Frame'
  439. if type(IconFrame) == 'string' then
  440. class = IconFrame
  441. IconFrame = nil
  442. end
  443.  
  444. if not IconFrame then
  445. IconFrame = Create(class,{
  446. Name = "Icon";
  447. BackgroundTransparency = 1;
  448. ClipsDescendants = true;
  449. Create('ImageLabel',{
  450. Name = "IconMap";
  451. Active = false;
  452. BackgroundTransparency = 1;
  453. Image = iconMap;
  454. Size = UDim2.new(mapSize.x/iconSize,0,mapSize.y/iconSize,0);
  455. });
  456. })
  457. end
  458.  
  459. IconFrame.IconMap.Position = UDim2.new(-col - (pad*(col+1) + border)/iconSize,0,-row - (pad*(row+1) + border)/iconSize,0)
  460. return IconFrame
  461. end
  462. end
  463.  
  464. ----------------------------------------------------------------
  465. ----------------------------------------------------------------
  466. ----------------------------------------------------------------
  467. ----------------------------------------------------------------
  468. ---- ScrollBar
  469. do
  470. -- AutoButtonColor doesn't always reset properly
  471. local function ResetButtonColor(button)
  472. local active = button.Active
  473. button.Active = not active
  474. button.Active = active
  475. end
  476.  
  477. local function ArrowGraphic(size,dir,scaled,template)
  478. local Frame = Create('Frame',{
  479. Name = "Arrow Graphic";
  480. BorderSizePixel = 0;
  481. Size = UDim2.new(0,size,0,size);
  482. Transparency = 1;
  483. })
  484. if not template then
  485. template = Instance.new("Frame")
  486. template.BorderSizePixel = 0
  487. end
  488.  
  489. local transform
  490. if dir == nil or dir == 'Up' then
  491. function transform(p,s) return p,s end
  492. elseif dir == 'Down' then
  493. function transform(p,s) return UDim2.new(0,p.X.Offset,0,size-p.Y.Offset-1),s end
  494. elseif dir == 'Left' then
  495. function transform(p,s) return UDim2.new(0,p.Y.Offset,0,p.X.Offset),UDim2.new(0,s.Y.Offset,0,s.X.Offset) end
  496. elseif dir == 'Right' then
  497. function transform(p,s) return UDim2.new(0,size-p.Y.Offset-1,0,p.X.Offset),UDim2.new(0,s.Y.Offset,0,s.X.Offset) end
  498. end
  499.  
  500. local scale
  501. if scaled then
  502. function scale(p,s) return UDim2.new(p.X.Offset/size,0,p.Y.Offset/size,0),UDim2.new(s.X.Offset/size,0,s.Y.Offset/size,0) end
  503. else
  504. function scale(p,s) return p,s end
  505. end
  506.  
  507. local o = math.floor(size/4)
  508. if size%2 == 0 then
  509. local n = size/2-1
  510. for i = 0,n do
  511. local t = template:Clone()
  512. local p,s = scale(transform(
  513. UDim2.new(0,n-i,0,o+i),
  514. UDim2.new(0,(i+1)*2,0,1)
  515. ))
  516. t.Position = p
  517. t.Size = s
  518. t.Parent = Frame
  519. end
  520. else
  521. local n = (size-1)/2
  522. for i = 0,n do
  523. local t = template:Clone()
  524. local p,s = scale(transform(
  525. UDim2.new(0,n-i,0,o+i),
  526. UDim2.new(0,i*2+1,0,1)
  527. ))
  528. t.Position = p
  529. t.Size = s
  530. t.Parent = Frame
  531. end
  532. end
  533. if size%4 > 1 then
  534. local t = template:Clone()
  535. local p,s = scale(transform(
  536. UDim2.new(0,0,0,size-o-1),
  537. UDim2.new(0,size,0,1)
  538. ))
  539. t.Position = p
  540. t.Size = s
  541. t.Parent = Frame
  542. end
  543. return Frame
  544. end
  545.  
  546.  
  547. local function GripGraphic(size,dir,spacing,scaled,template)
  548. local Frame = Create('Frame',{
  549. Name = "Grip Graphic";
  550. BorderSizePixel = 0;
  551. Size = UDim2.new(0,size.x,0,size.y);
  552. Transparency = 1;
  553. })
  554. if not template then
  555. template = Instance.new("Frame")
  556. template.BorderSizePixel = 0
  557. end
  558.  
  559. spacing = spacing or 2
  560.  
  561. local scale
  562. if scaled then
  563. function scale(p) return UDim2.new(p.X.Offset/size.x,0,p.Y.Offset/size.y,0) end
  564. else
  565. function scale(p) return p end
  566. end
  567.  
  568. if dir == 'Vertical' then
  569. for i=0,size.x-1,spacing do
  570. local t = template:Clone()
  571. t.Size = scale(UDim2.new(0,1,0,size.y))
  572. t.Position = scale(UDim2.new(0,i,0,0))
  573. t.Parent = Frame
  574. end
  575. elseif dir == nil or dir == 'Horizontal' then
  576. for i=0,size.y-1,spacing do
  577. local t = template:Clone()
  578. t.Size = scale(UDim2.new(0,size.x,0,1))
  579. t.Position = scale(UDim2.new(0,0,0,i))
  580. t.Parent = Frame
  581. end
  582. end
  583.  
  584. return Frame
  585. end
  586.  
  587. local mt = {
  588. __index = {
  589. GetScrollPercent = function(self)
  590. return self.ScrollIndex/(self.TotalSpace-self.VisibleSpace)
  591. end;
  592. CanScrollDown = function(self)
  593. return self.ScrollIndex + self.VisibleSpace < self.TotalSpace
  594. end;
  595. CanScrollUp = function(self)
  596. return self.ScrollIndex > 0
  597. end;
  598. ScrollDown = function(self)
  599. self.ScrollIndex = self.ScrollIndex + self.PageIncrement
  600. self:Update()
  601. end;
  602. ScrollUp = function(self)
  603. self.ScrollIndex = self.ScrollIndex - self.PageIncrement
  604. self:Update()
  605. end;
  606. ScrollTo = function(self,index)
  607. self.ScrollIndex = index
  608. self:Update()
  609. end;
  610. SetScrollPercent = function(self,percent)
  611. self.ScrollIndex = math.floor((self.TotalSpace - self.VisibleSpace)*percent + 0.5)
  612. self:Update()
  613. end;
  614. };
  615. }
  616. mt.__index.CanScrollRight = mt.__index.CanScrollDown
  617. mt.__index.CanScrollLeft = mt.__index.CanScrollUp
  618. mt.__index.ScrollLeft = mt.__index.ScrollUp
  619. mt.__index.ScrollRight = mt.__index.ScrollDown
  620.  
  621. function ScrollBar(horizontal)
  622. -- create row scroll bar
  623. local ScrollFrame = Create('Frame',{
  624. Name = "ScrollFrame";
  625. Position = horizontal and UDim2.new(0,0,1,-GUI_SIZE) or UDim2.new(1,-GUI_SIZE,0,0);
  626. Size = horizontal and UDim2.new(1,0,0,GUI_SIZE) or UDim2.new(0,GUI_SIZE,1,0);
  627. BackgroundTransparency = 1;
  628. Create('ImageButton',{
  629. Name = "ScrollDown";
  630. Position = horizontal and UDim2.new(1,-GUI_SIZE,0,0) or UDim2.new(0,0,1,-GUI_SIZE);
  631. Size = UDim2.new(0, GUI_SIZE, 0, GUI_SIZE);
  632. BackgroundColor3 = GuiColor.Button;
  633. BorderColor3 = GuiColor.Border;
  634. --BorderSizePixel = 0;
  635. });
  636. Create('ImageButton',{
  637. Name = "ScrollUp";
  638. Size = UDim2.new(0, GUI_SIZE, 0, GUI_SIZE);
  639. BackgroundColor3 = GuiColor.Button;
  640. BorderColor3 = GuiColor.Border;
  641. --BorderSizePixel = 0;
  642. });
  643. Create('ImageButton',{
  644. Name = "ScrollBar";
  645. Size = horizontal and UDim2.new(1,-GUI_SIZE*2,1,0) or UDim2.new(1,0,1,-GUI_SIZE*2);
  646. Position = horizontal and UDim2.new(0,GUI_SIZE,0,0) or UDim2.new(0,0,0,GUI_SIZE);
  647. AutoButtonColor = false;
  648. BackgroundColor3 = Color3.new(0.94902, 0.94902, 0.94902);
  649. BorderColor3 = GuiColor.Border;
  650. --BorderSizePixel = 0;
  651. Create('ImageButton',{
  652. Name = "ScrollThumb";
  653. AutoButtonColor = false;
  654. Size = UDim2.new(0, GUI_SIZE, 0, GUI_SIZE);
  655. BackgroundColor3 = GuiColor.Button;
  656. BorderColor3 = GuiColor.Border;
  657. --BorderSizePixel = 0;
  658. });
  659. });
  660. })
  661.  
  662. local graphicTemplate = Create('Frame',{
  663. Name="Graphic";
  664. BorderSizePixel = 0;
  665. BackgroundColor3 = GuiColor.Border;
  666. })
  667. local graphicSize = GUI_SIZE/2
  668.  
  669. local ScrollDownFrame = ScrollFrame.ScrollDown
  670. local ScrollDownGraphic = ArrowGraphic(graphicSize,horizontal and 'Right' or 'Down',true,graphicTemplate)
  671. ScrollDownGraphic.Position = UDim2.new(0.5,-graphicSize/2,0.5,-graphicSize/2)
  672. ScrollDownGraphic.Parent = ScrollDownFrame
  673. local ScrollUpFrame = ScrollFrame.ScrollUp
  674. local ScrollUpGraphic = ArrowGraphic(graphicSize,horizontal and 'Left' or 'Up',true,graphicTemplate)
  675. ScrollUpGraphic.Position = UDim2.new(0.5,-graphicSize/2,0.5,-graphicSize/2)
  676. ScrollUpGraphic.Parent = ScrollUpFrame
  677. local ScrollBarFrame = ScrollFrame.ScrollBar
  678. local ScrollThumbFrame = ScrollBarFrame.ScrollThumb
  679. do
  680. local size = GUI_SIZE*3/8
  681. local Decal = GripGraphic(Vector2.new(size,size),horizontal and 'Vertical' or 'Horizontal',2,graphicTemplate)
  682. Decal.Position = UDim2.new(0.5,-size/2,0.5,-size/2)
  683. Decal.Parent = ScrollThumbFrame
  684. end
  685.  
  686. local Class = setmetatable({
  687. GUI = ScrollFrame;
  688. ScrollIndex = 0;
  689. VisibleSpace = 0;
  690. TotalSpace = 0;
  691. PageIncrement = 1;
  692. },mt)
  693.  
  694. local UpdateScrollThumb
  695. if horizontal then
  696. function UpdateScrollThumb()
  697. ScrollThumbFrame.Size = UDim2.new(Class.VisibleSpace/Class.TotalSpace,0,0,GUI_SIZE)
  698. if ScrollThumbFrame.AbsoluteSize.x < GUI_SIZE then
  699. ScrollThumbFrame.Size = UDim2.new(0,GUI_SIZE,0,GUI_SIZE)
  700. end
  701. local barSize = ScrollBarFrame.AbsoluteSize.x
  702. ScrollThumbFrame.Position = UDim2.new(Class:GetScrollPercent()*(barSize - ScrollThumbFrame.AbsoluteSize.x)/barSize,0,0,0)
  703. end
  704. else
  705. function UpdateScrollThumb()
  706. ScrollThumbFrame.Size = UDim2.new(0,GUI_SIZE,Class.VisibleSpace/Class.TotalSpace,0)
  707. if ScrollThumbFrame.AbsoluteSize.y < GUI_SIZE then
  708. ScrollThumbFrame.Size = UDim2.new(0,GUI_SIZE,0,GUI_SIZE)
  709. end
  710. local barSize = ScrollBarFrame.AbsoluteSize.y
  711. ScrollThumbFrame.Position = UDim2.new(0,0,Class:GetScrollPercent()*(barSize - ScrollThumbFrame.AbsoluteSize.y)/barSize,0)
  712. end
  713. end
  714.  
  715. local lastDown
  716. local lastUp
  717. local scrollStyle = {BackgroundColor3=GuiColor.Border,BackgroundTransparency=0}
  718. local scrollStyle_ds = {BackgroundColor3=GuiColor.Border,BackgroundTransparency=0.7}
  719.  
  720. local function Update()
  721. local t = Class.TotalSpace
  722. local v = Class.VisibleSpace
  723. local s = Class.ScrollIndex
  724. if v <= t then
  725. if s > 0 then
  726. if s + v > t then
  727. Class.ScrollIndex = t - v
  728. end
  729. else
  730. Class.ScrollIndex = 0
  731. end
  732. else
  733. Class.ScrollIndex = 0
  734. end
  735.  
  736. if Class.UpdateCallback then
  737. if Class.UpdateCallback(Class) == false then
  738. return
  739. end
  740. end
  741.  
  742. local down = Class:CanScrollDown()
  743. local up = Class:CanScrollUp()
  744. if down ~= lastDown then
  745. lastDown = down
  746. ScrollDownFrame.Active = down
  747. ScrollDownFrame.AutoButtonColor = down
  748. local children = ScrollDownGraphic:GetChildren()
  749. local style = down and scrollStyle or scrollStyle_ds
  750. for i = 1,#children do
  751. Create(children[i],style)
  752. end
  753. end
  754. if up ~= lastUp then
  755. lastUp = up
  756. ScrollUpFrame.Active = up
  757. ScrollUpFrame.AutoButtonColor = up
  758. local children = ScrollUpGraphic:GetChildren()
  759. local style = up and scrollStyle or scrollStyle_ds
  760. for i = 1,#children do
  761. Create(children[i],style)
  762. end
  763. end
  764. ScrollThumbFrame.Visible = down or up
  765. UpdateScrollThumb()
  766. end
  767. Class.Update = Update
  768.  
  769. SetZIndexOnChanged(ScrollFrame)
  770.  
  771. local MouseDrag = Create('ImageButton',{
  772. Name = "MouseDrag";
  773. Position = UDim2.new(-0.25,0,-0.25,0);
  774. Size = UDim2.new(1.5,0,1.5,0);
  775. Transparency = 1;
  776. AutoButtonColor = false;
  777. Active = true;
  778. ZIndex = 10;
  779. })
  780.  
  781. local scrollEventID = 0
  782. ScrollDownFrame.MouseButton1Down:connect(function()
  783. scrollEventID = tick()
  784. local current = scrollEventID
  785. local up_con
  786. up_con = MouseDrag.MouseButton1Up:connect(function()
  787. scrollEventID = tick()
  788. MouseDrag.Parent = nil
  789. ResetButtonColor(ScrollDownFrame)
  790. up_con:disconnect(); drag = nil
  791. end)
  792. MouseDrag.Parent = GetScreen(ScrollFrame)
  793. Class:ScrollDown()
  794. wait(0.2) -- delay before auto scroll
  795. while scrollEventID == current do
  796. Class:ScrollDown()
  797. if not Class:CanScrollDown() then break end
  798. wait()
  799. end
  800. end)
  801.  
  802. ScrollDownFrame.MouseButton1Up:connect(function()
  803. scrollEventID = tick()
  804. end)
  805.  
  806. ScrollUpFrame.MouseButton1Down:connect(function()
  807. scrollEventID = tick()
  808. local current = scrollEventID
  809. local up_con
  810. up_con = MouseDrag.MouseButton1Up:connect(function()
  811. scrollEventID = tick()
  812. MouseDrag.Parent = nil
  813. ResetButtonColor(ScrollUpFrame)
  814. up_con:disconnect(); drag = nil
  815. end)
  816. MouseDrag.Parent = GetScreen(ScrollFrame)
  817. Class:ScrollUp()
  818. wait(0.2)
  819. while scrollEventID == current do
  820. Class:ScrollUp()
  821. if not Class:CanScrollUp() then break end
  822. wait()
  823. end
  824. end)
  825.  
  826. ScrollUpFrame.MouseButton1Up:connect(function()
  827. scrollEventID = tick()
  828. end)
  829.  
  830. if horizontal then
  831. ScrollBarFrame.MouseButton1Down:connect(function(x,y)
  832. scrollEventID = tick()
  833. local current = scrollEventID
  834. local up_con
  835. up_con = MouseDrag.MouseButton1Up:connect(function()
  836. scrollEventID = tick()
  837. MouseDrag.Parent = nil
  838. ResetButtonColor(ScrollUpFrame)
  839. up_con:disconnect(); drag = nil
  840. end)
  841. MouseDrag.Parent = GetScreen(ScrollFrame)
  842. if x > ScrollThumbFrame.AbsolutePosition.x then
  843. Class:ScrollTo(Class.ScrollIndex + Class.VisibleSpace)
  844. wait(0.2)
  845. while scrollEventID == current do
  846. if x < ScrollThumbFrame.AbsolutePosition.x + ScrollThumbFrame.AbsoluteSize.x then break end
  847. Class:ScrollTo(Class.ScrollIndex + Class.VisibleSpace)
  848. wait()
  849. end
  850. else
  851. Class:ScrollTo(Class.ScrollIndex - Class.VisibleSpace)
  852. wait(0.2)
  853. while scrollEventID == current do
  854. if x > ScrollThumbFrame.AbsolutePosition.x then break end
  855. Class:ScrollTo(Class.ScrollIndex - Class.VisibleSpace)
  856. wait()
  857. end
  858. end
  859. end)
  860. else
  861. ScrollBarFrame.MouseButton1Down:connect(function(x,y)
  862. scrollEventID = tick()
  863. local current = scrollEventID
  864. local up_con
  865. up_con = MouseDrag.MouseButton1Up:connect(function()
  866. scrollEventID = tick()
  867. MouseDrag.Parent = nil
  868. ResetButtonColor(ScrollUpFrame)
  869. up_con:disconnect(); drag = nil
  870. end)
  871. MouseDrag.Parent = GetScreen(ScrollFrame)
  872. if y > ScrollThumbFrame.AbsolutePosition.y then
  873. Class:ScrollTo(Class.ScrollIndex + Class.VisibleSpace)
  874. wait(0.2)
  875. while scrollEventID == current do
  876. if y < ScrollThumbFrame.AbsolutePosition.y + ScrollThumbFrame.AbsoluteSize.y then break end
  877. Class:ScrollTo(Class.ScrollIndex + Class.VisibleSpace)
  878. wait()
  879. end
  880. else
  881. Class:ScrollTo(Class.ScrollIndex - Class.VisibleSpace)
  882. wait(0.2)
  883. while scrollEventID == current do
  884. if y > ScrollThumbFrame.AbsolutePosition.y then break end
  885. Class:ScrollTo(Class.ScrollIndex - Class.VisibleSpace)
  886. wait()
  887. end
  888. end
  889. end)
  890. end
  891.  
  892. if horizontal then
  893. ScrollThumbFrame.MouseButton1Down:connect(function(x,y)
  894. scrollEventID = tick()
  895. local mouse_offset = x - ScrollThumbFrame.AbsolutePosition.x
  896. local drag_con
  897. local up_con
  898. drag_con = MouseDrag.MouseMoved:connect(function(x,y)
  899. local bar_abs_pos = ScrollBarFrame.AbsolutePosition.x
  900. local bar_drag = ScrollBarFrame.AbsoluteSize.x - ScrollThumbFrame.AbsoluteSize.x
  901. local bar_abs_one = bar_abs_pos + bar_drag
  902. x = x - mouse_offset
  903. x = x < bar_abs_pos and bar_abs_pos or x > bar_abs_one and bar_abs_one or x
  904. x = x - bar_abs_pos
  905. Class:SetScrollPercent(x/(bar_drag))
  906. end)
  907. up_con = MouseDrag.MouseButton1Up:connect(function()
  908. scrollEventID = tick()
  909. MouseDrag.Parent = nil
  910. ResetButtonColor(ScrollThumbFrame)
  911. drag_con:disconnect(); drag_con = nil
  912. up_con:disconnect(); drag = nil
  913. end)
  914. MouseDrag.Parent = GetScreen(ScrollFrame)
  915. end)
  916. else
  917. ScrollThumbFrame.MouseButton1Down:connect(function(x,y)
  918. scrollEventID = tick()
  919. local mouse_offset = y - ScrollThumbFrame.AbsolutePosition.y
  920. local drag_con
  921. local up_con
  922. drag_con = MouseDrag.MouseMoved:connect(function(x,y)
  923. local bar_abs_pos = ScrollBarFrame.AbsolutePosition.y
  924. local bar_drag = ScrollBarFrame.AbsoluteSize.y - ScrollThumbFrame.AbsoluteSize.y
  925. local bar_abs_one = bar_abs_pos + bar_drag
  926. y = y - mouse_offset
  927. y = y < bar_abs_pos and bar_abs_pos or y > bar_abs_one and bar_abs_one or y
  928. y = y - bar_abs_pos
  929. Class:SetScrollPercent(y/(bar_drag))
  930. end)
  931. up_con = MouseDrag.MouseButton1Up:connect(function()
  932. scrollEventID = tick()
  933. MouseDrag.Parent = nil
  934. ResetButtonColor(ScrollThumbFrame)
  935. drag_con:disconnect(); drag_con = nil
  936. up_con:disconnect(); drag = nil
  937. end)
  938. MouseDrag.Parent = GetScreen(ScrollFrame)
  939. end)
  940. end
  941.  
  942. function Class:Destroy()
  943. ScrollFrame:Destroy()
  944. MouseDrag:Destroy()
  945. for k in pairs(Class) do
  946. Class[k] = nil
  947. end
  948. setmetatable(Class,nil)
  949. end
  950.  
  951. Update()
  952.  
  953. return Class
  954. end
  955. end
  956.  
  957. ----------------------------------------------------------------
  958. ----------------------------------------------------------------
  959. ----------------------------------------------------------------
  960. ----------------------------------------------------------------
  961. ---- Explorer panel
  962.  
  963. local explorerPanel = script.Parent
  964. Create(explorerPanel,{
  965. BackgroundColor3 = GuiColor.Field;
  966. BorderColor3 = GuiColor.Border;
  967. Active = true;
  968. })
  969.  
  970. local listFrame = Create('Frame',{
  971. Name = "List";
  972. BackgroundTransparency = 1;
  973. ClipsDescendants = true;
  974. Position = UDim2.new(0,0,0,HEADER_SIZE);
  975. Size = UDim2.new(1,-GUI_SIZE,1,-HEADER_SIZE);
  976. Parent = explorerPanel;
  977. })
  978.  
  979. local scrollBar = ScrollBar(false)
  980. scrollBar.PageIncrement = 1
  981. Create(scrollBar.GUI,{
  982. Position = UDim2.new(1,-GUI_SIZE,0,HEADER_SIZE);
  983. Size = UDim2.new(0,GUI_SIZE,1,-HEADER_SIZE);
  984. Parent = explorerPanel;
  985. })
  986.  
  987. local scrollBarH = ScrollBar(true)
  988. scrollBarH.PageIncrement = GUI_SIZE
  989. Create(scrollBarH.GUI,{
  990. Position = UDim2.new(0,0,1,-GUI_SIZE);
  991. Size = UDim2.new(1,-GUI_SIZE,0,GUI_SIZE);
  992. Visible = false;
  993. Parent = explorerPanel;
  994. })
  995.  
  996. local headerFrame = Create('Frame',{
  997. Name = "Header";
  998. BackgroundColor3 = GuiColor.Background;
  999. BorderColor3 = GuiColor.Border;
  1000. Position = UDim2.new(0,0,0,0);
  1001. Size = UDim2.new(1,0,0,HEADER_SIZE);
  1002. Parent = explorerPanel;
  1003. Create('TextLabel',{
  1004. Text = "Explorer";
  1005. BackgroundTransparency = 1;
  1006. TextColor3 = GuiColor.Text;
  1007. TextXAlignment = 'Left';
  1008. Font = FONT;
  1009. FontSize = FONT_SIZE;
  1010. Position = UDim2.new(0,4,0,0);
  1011. Size = UDim2.new(1,-4,1,0);
  1012. });
  1013. })
  1014.  
  1015. SetZIndexOnChanged(explorerPanel)
  1016.  
  1017. local getTextWidth do
  1018. local text = Create('TextLabel',{
  1019. Name = "TextWidth";
  1020. TextXAlignment = 'Left';
  1021. TextYAlignment = 'Center';
  1022. Font = FONT;
  1023. FontSize = FONT_SIZE;
  1024. Text = "";
  1025. Position = UDim2.new(0,0,0,0);
  1026. Size = UDim2.new(1,0,1,0);
  1027. Visible = false;
  1028. Parent = explorerPanel;
  1029. })
  1030. function getTextWidth(s)
  1031. text.Text = s
  1032. return text.TextBounds.x
  1033. end
  1034. end
  1035.  
  1036. -- Holds the game tree converted to a list.
  1037. local TreeList = {}
  1038. -- Matches objects to their tree node representation.
  1039. local NodeLookup = {}
  1040.  
  1041. local nodeWidth = 0
  1042.  
  1043. local updateList,rawUpdateList,updateScroll,rawUpdateSize do
  1044. local function r(t)
  1045. for i = 1,#t do
  1046. TreeList[#TreeList+1] = t[i]
  1047.  
  1048. local w = (t[i].Depth)*(2+ENTRY_PADDING+GUI_SIZE) + 2 + ENTRY_SIZE + 4 + getTextWidth(t[i].Object.Name) + 4
  1049. if w > nodeWidth then
  1050. nodeWidth = w
  1051. end
  1052. if t[i].Expanded then
  1053. r(t[i])
  1054. end
  1055. end
  1056. end
  1057.  
  1058. function rawUpdateSize()
  1059. scrollBarH.TotalSpace = nodeWidth
  1060. scrollBarH.VisibleSpace = listFrame.AbsoluteSize.x
  1061. scrollBarH:Update()
  1062. local visible = scrollBarH:CanScrollDown() or scrollBarH:CanScrollUp()
  1063. scrollBarH.GUI.Visible = visible
  1064.  
  1065. listFrame.Size = UDim2.new(1,-GUI_SIZE,1,-GUI_SIZE*(visible and 1 or 0) - HEADER_SIZE)
  1066.  
  1067. scrollBar.VisibleSpace = math.ceil(listFrame.AbsoluteSize.y/ENTRY_BOUND)
  1068. scrollBar.GUI.Size = UDim2.new(0,GUI_SIZE,1,-GUI_SIZE*(visible and 1 or 0) - HEADER_SIZE)
  1069.  
  1070. scrollBar.TotalSpace = #TreeList+1
  1071. scrollBar:Update()
  1072. end
  1073.  
  1074. function rawUpdateList()
  1075. -- Clear then repopulate the entire list. It appears to be fast enough.
  1076. TreeList = {}
  1077. nodeWidth = 0
  1078. r(NodeLookup[Game])
  1079. rawUpdateSize()
  1080. end
  1081.  
  1082. -- Adding or removing large models will cause many updates to occur. We
  1083. -- can reduce the number of updates by creating a delay, then dropping any
  1084. -- updates that occur during the delay.
  1085. local updatingList = false
  1086. function updateList()
  1087. if updatingList then return end
  1088. updatingList = true
  1089. wait(0.25)
  1090. updatingList = false
  1091. rawUpdateList()
  1092. end
  1093.  
  1094. local updatingScroll = false
  1095. function updateScroll()
  1096. if updatingScroll then return end
  1097. updatingScroll = true
  1098. wait(0.25)
  1099. updatingScroll = false
  1100. scrollBar:Update()
  1101. end
  1102. end
  1103.  
  1104. local Selection do
  1105. local bindGetSelection = script.Parent:FindFirstChild("GetSelection")
  1106. if not bindGetSelection then
  1107. bindGetSelection = Create('BindableFunction',{Name = "GetSelection"})
  1108. bindGetSelection.Parent = script.Parent
  1109. end
  1110.  
  1111. local bindSetSelection = script.Parent:FindFirstChild("SetSelection")
  1112. if not bindSetSelection then
  1113. bindSetSelection = Create('BindableFunction',{Name = "SetSelection"})
  1114. bindSetSelection.Parent = script.Parent
  1115. end
  1116.  
  1117. local bindSelectionChanged = script.Parent:FindFirstChild("SelectionChanged")
  1118. if not bindSelectionChanged then
  1119. bindSelectionChanged = Create('BindableEvent',{Name = "SelectionChanged"})
  1120. bindSelectionChanged.Parent = script.Parent
  1121. end
  1122.  
  1123. local SelectionList = {}
  1124. local SelectionSet = {}
  1125. Selection = {
  1126. Selected = SelectionSet;
  1127. List = SelectionList;
  1128. }
  1129.  
  1130. local function addObject(object)
  1131. -- list update
  1132. local lupdate = false
  1133. -- scroll update
  1134. local supdate = false
  1135.  
  1136. if not SelectionSet[object] then
  1137. local node = NodeLookup[object]
  1138. if node then
  1139. table.insert(SelectionList,object)
  1140. SelectionSet[object] = true
  1141. node.Selected = true
  1142.  
  1143. -- expand all ancestors so that selected node becomes visible
  1144. node = node.Parent
  1145. while node do
  1146. if not node.Expanded then
  1147. node.Expanded = true
  1148. lupdate = true
  1149. end
  1150. node = node.Parent
  1151. end
  1152. supdate = true
  1153. end
  1154. end
  1155. return lupdate,supdate
  1156. end
  1157.  
  1158. function Selection:Set(objects)
  1159. local lupdate = false
  1160. local supdate = false
  1161.  
  1162. if #SelectionList > 0 then
  1163. for i = 1,#SelectionList do
  1164. local object = SelectionList[i]
  1165. local node = NodeLookup[object]
  1166. if node then
  1167. node.Selected = false
  1168. SelectionSet[object] = nil
  1169. end
  1170. end
  1171.  
  1172. SelectionList = {}
  1173. Selection.List = SelectionList
  1174. supdate = true
  1175. end
  1176.  
  1177. for i = 1,#objects do
  1178. local l,s = addObject(objects[i])
  1179. lupdate = l or lupdate
  1180. supdate = s or supdate
  1181. end
  1182.  
  1183. if lupdate then
  1184. rawUpdateList()
  1185. supdate = true
  1186. elseif supdate then
  1187. scrollBar:Update()
  1188. end
  1189.  
  1190. if supdate then
  1191. bindSelectionChanged:Fire()
  1192. end
  1193. end
  1194.  
  1195. function Selection:Add(object)
  1196. local l,s = addObject(object)
  1197. if l then
  1198. rawUpdateList()
  1199. bindSelectionChanged:Fire()
  1200. elseif s then
  1201. scrollBar:Update()
  1202. bindSelectionChanged:Fire()
  1203. end
  1204. end
  1205.  
  1206. function Selection:Remove(object,noupdate)
  1207. if SelectionSet[object] then
  1208. local node = NodeLookup[object]
  1209. if node then
  1210. node.Selected = false
  1211. SelectionSet[object] = nil
  1212. for i = 1,#SelectionList do
  1213. if SelectionList[i] == object then
  1214. table.remove(SelectionList,i)
  1215. break
  1216. end
  1217. end
  1218.  
  1219. if not noupdate then
  1220. scrollBar:Update()
  1221. end
  1222. bindSelectionChanged:Fire()
  1223. end
  1224. end
  1225. end
  1226.  
  1227. function Selection:Get()
  1228. local list = {}
  1229. for i = 1,#SelectionList do
  1230. list[i] = SelectionList[i]
  1231. end
  1232. return list
  1233. end
  1234.  
  1235. bindSetSelection.OnInvoke = function(...)
  1236. Selection:Set(...)
  1237. end
  1238.  
  1239. bindGetSelection.OnInvoke = function()
  1240. return Selection:Get()
  1241. end
  1242. end
  1243.  
  1244. local function cancelReparentDrag()end
  1245. local function cancelSelectDrag()end
  1246. do
  1247. local listEntries = {}
  1248. local nameConnLookup = {}
  1249.  
  1250. local mouseDrag = Create('ImageButton',{
  1251. Name = "MouseDrag";
  1252. Position = UDim2.new(-0.25,0,-0.25,0);
  1253. Size = UDim2.new(1.5,0,1.5,0);
  1254. Transparency = 1;
  1255. AutoButtonColor = false;
  1256. Active = true;
  1257. ZIndex = 10;
  1258. })
  1259. local function dragSelect(last,add,button)
  1260. local connDrag
  1261. local conUp
  1262.  
  1263. conDrag = mouseDrag.MouseMoved:connect(function(x,y)
  1264. local pos = Vector2.new(x,y) - listFrame.AbsolutePosition
  1265. local size = listFrame.AbsoluteSize
  1266. if pos.x < 0 or pos.x > size.x or pos.y < 0 or pos.y > size.y then return end
  1267.  
  1268. local i = math.ceil(pos.y/ENTRY_BOUND) + scrollBar.ScrollIndex
  1269. -- Mouse may have made a large step, so interpolate between the
  1270. -- last index and the current.
  1271. for n = i<last and i or last, i>last and i or last do
  1272. local node = TreeList[n]
  1273. if node then
  1274. if add then
  1275. Selection:Add(node.Object)
  1276. else
  1277. Selection:Remove(node.Object)
  1278. end
  1279. end
  1280. end
  1281. last = i
  1282. end)
  1283.  
  1284. function cancelSelectDrag()
  1285. mouseDrag.Parent = nil
  1286. conDrag:disconnect()
  1287. conUp:disconnect()
  1288. function cancelSelectDrag()end
  1289. end
  1290.  
  1291. conUp = mouseDrag[button]:connect(cancelSelectDrag)
  1292.  
  1293. mouseDrag.Parent = GetScreen(listFrame)
  1294. end
  1295.  
  1296. local function dragReparent(object,dragGhost,clickPos,ghostOffset)
  1297. local connDrag
  1298. local conUp
  1299. local conUp2
  1300.  
  1301. local parentIndex = nil
  1302. local dragged = false
  1303.  
  1304. local parentHighlight = Create('Frame',{
  1305. Transparency = 1;
  1306. Visible = false;
  1307. Create('Frame',{
  1308. BorderSizePixel = 0;
  1309. BackgroundColor3 = Color3.new(0,0,0);
  1310. BackgroundTransparency = 0.1;
  1311. Position = UDim2.new(0,0,0,0);
  1312. Size = UDim2.new(1,0,0,1);
  1313. });
  1314. Create('Frame',{
  1315. BorderSizePixel = 0;
  1316. BackgroundColor3 = Color3.new(0,0,0);
  1317. BackgroundTransparency = 0.1;
  1318. Position = UDim2.new(1,0,0,0);
  1319. Size = UDim2.new(0,1,1,0);
  1320. });
  1321. Create('Frame',{
  1322. BorderSizePixel = 0;
  1323. BackgroundColor3 = Color3.new(0,0,0);
  1324. BackgroundTransparency = 0.1;
  1325. Position = UDim2.new(0,0,1,0);
  1326. Size = UDim2.new(1,0,0,1);
  1327. });
  1328. Create('Frame',{
  1329. BorderSizePixel = 0;
  1330. BackgroundColor3 = Color3.new(0,0,0);
  1331. BackgroundTransparency = 0.1;
  1332. Position = UDim2.new(0,0,0,0);
  1333. Size = UDim2.new(0,1,1,0);
  1334. });
  1335. })
  1336. SetZIndex(parentHighlight,9)
  1337.  
  1338. conDrag = mouseDrag.MouseMoved:connect(function(x,y)
  1339. local dragPos = Vector2.new(x,y)
  1340. if dragged then
  1341. local pos = dragPos - listFrame.AbsolutePosition
  1342. local size = listFrame.AbsoluteSize
  1343.  
  1344. parentIndex = nil
  1345. parentHighlight.Visible = false
  1346. if pos.x >= 0 and pos.x <= size.x and pos.y >= 0 and pos.y <= size.y then
  1347. local i = math.ceil(pos.y/ENTRY_BOUND)
  1348. local node = TreeList[i + scrollBar.ScrollIndex]
  1349. if node and node.Object ~= object and not object:IsAncestorOf(node.Object) then
  1350. parentIndex = i
  1351. local entry = listEntries[i]
  1352. if entry then
  1353. parentHighlight.Visible = true
  1354. parentHighlight.Position = UDim2.new(0,1,0,entry.AbsolutePosition.y-listFrame.AbsolutePosition.y)
  1355. parentHighlight.Size = UDim2.new(0,size.x-4,0,entry.AbsoluteSize.y)
  1356. end
  1357. end
  1358. end
  1359.  
  1360. dragGhost.Position = UDim2.new(0,dragPos.x+ghostOffset.x,0,dragPos.y+ghostOffset.y)
  1361. elseif (clickPos-dragPos).magnitude > 8 then
  1362. dragged = true
  1363. SetZIndex(dragGhost,9)
  1364. dragGhost.IndentFrame.Transparency = 0.25
  1365. dragGhost.IndentFrame.EntryText.TextColor3 = GuiColor.TextSelected
  1366. dragGhost.Position = UDim2.new(0,dragPos.x+ghostOffset.x,0,dragPos.y+ghostOffset.y)
  1367. dragGhost.Parent = GetScreen(listFrame)
  1368. parentHighlight.Parent = listFrame
  1369. end
  1370. end)
  1371.  
  1372. function cancelReparentDrag()
  1373. mouseDrag.Parent = nil
  1374. conDrag:disconnect()
  1375. conUp:disconnect()
  1376. conUp2:disconnect()
  1377. dragGhost:Destroy()
  1378. parentHighlight:Destroy()
  1379. function cancelReparentDrag()end
  1380. end
  1381.  
  1382. local wasSelected = Selection.Selected[object]
  1383. if not wasSelected and Option.Selectable then
  1384. Selection:Set({object})
  1385. end
  1386.  
  1387. conUp = mouseDrag.MouseButton1Up:connect(function()
  1388. cancelReparentDrag()
  1389. if dragged then
  1390. if parentIndex then
  1391. local parentNode = TreeList[parentIndex + scrollBar.ScrollIndex]
  1392. if parentNode then
  1393. parentNode.Expanded = true
  1394.  
  1395. local parentObj = parentNode.Object
  1396. local function parent(a,b)
  1397. a.Parent = b
  1398. end
  1399. if Option.Selectable then
  1400. local list = Selection.List
  1401. for i = 1,#list do
  1402. pcall(parent,list[i],parentObj)
  1403. end
  1404. else
  1405. pcall(parent,object,parentObj)
  1406. end
  1407. end
  1408. end
  1409. else
  1410. -- do selection click
  1411. if wasSelected and Option.Selectable then
  1412. Selection:Set({})
  1413. end
  1414. end
  1415. end)
  1416. conUp2 = mouseDrag.MouseButton2Down:connect(function()
  1417. cancelReparentDrag()
  1418. end)
  1419.  
  1420. mouseDrag.Parent = GetScreen(listFrame)
  1421. end
  1422.  
  1423. local entryTemplate = Create('ImageButton',{
  1424. Name = "Entry";
  1425. Transparency = 1;
  1426. AutoButtonColor = false;
  1427. Position = UDim2.new(0,0,0,0);
  1428. Size = UDim2.new(1,0,0,ENTRY_SIZE);
  1429. Create('Frame',{
  1430. Name = "IndentFrame";
  1431. BackgroundTransparency = 1;
  1432. BackgroundColor3 = GuiColor.Selected;
  1433. BorderColor3 = GuiColor.BorderSelected;
  1434. Position = UDim2.new(0,0,0,0);
  1435. Size = UDim2.new(1,0,1,0);
  1436. Create(Icon('ImageButton',0),{
  1437. Name = "Expand";
  1438. AutoButtonColor = false;
  1439. Position = UDim2.new(0,-GUI_SIZE,0.5,-GUI_SIZE/2);
  1440. Size = UDim2.new(0,GUI_SIZE,0,GUI_SIZE);
  1441. });
  1442. Create(Icon(nil,0),{
  1443. Name = "ExplorerIcon";
  1444. Position = UDim2.new(0,2+ENTRY_PADDING,0.5,-GUI_SIZE/2);
  1445. Size = UDim2.new(0,GUI_SIZE,0,GUI_SIZE);
  1446. });
  1447. Create('TextLabel',{
  1448. Name = "EntryText";
  1449. BackgroundTransparency = 1;
  1450. TextColor3 = GuiColor.Text;
  1451. TextXAlignment = 'Left';
  1452. TextYAlignment = 'Center';
  1453. Font = FONT;
  1454. FontSize = FONT_SIZE;
  1455. Text = "";
  1456. Position = UDim2.new(0,2+ENTRY_SIZE+4,0,0);
  1457. Size = UDim2.new(1,-2,1,0);
  1458. });
  1459. });
  1460. })
  1461.  
  1462. function scrollBar.UpdateCallback(self)
  1463. for i = 1,self.VisibleSpace do
  1464. local node = TreeList[i + self.ScrollIndex]
  1465. if node then
  1466. local entry = listEntries[i]
  1467. if not entry then
  1468. entry = Create(entryTemplate:Clone(),{
  1469. Position = UDim2.new(0,2,0,ENTRY_BOUND*(i-1)+2);
  1470. Size = UDim2.new(0,nodeWidth,0,ENTRY_SIZE);
  1471. ZIndex = listFrame.ZIndex;
  1472. })
  1473. listEntries[i] = entry
  1474.  
  1475. local expand = entry.IndentFrame.Expand
  1476. expand.MouseEnter:connect(function()
  1477. local node = TreeList[i + self.ScrollIndex]
  1478. if #node > 0 then
  1479. if node.Expanded then
  1480. Icon(expand,NODE_EXPANDED_OVER)
  1481. else
  1482. Icon(expand,NODE_COLLAPSED_OVER)
  1483. end
  1484. end
  1485. end)
  1486. expand.MouseLeave:connect(function()
  1487. local node = TreeList[i + self.ScrollIndex]
  1488. if #node > 0 then
  1489. if node.Expanded then
  1490. Icon(expand,NODE_EXPANDED)
  1491. else
  1492. Icon(expand,NODE_COLLAPSED)
  1493. end
  1494. end
  1495. end)
  1496. expand.MouseButton1Down:connect(function()
  1497. local node = TreeList[i + self.ScrollIndex]
  1498. if #node > 0 then
  1499. node.Expanded = not node.Expanded
  1500. -- use raw update so the list updates instantly
  1501. rawUpdateList()
  1502. end
  1503. end)
  1504.  
  1505. entry.MouseButton1Down:connect(function(x,y)
  1506. local node = TreeList[i + self.ScrollIndex]
  1507. if Option.Modifiable then
  1508. local pos = Vector2.new(x,y)
  1509. dragReparent(node.Object,entry:Clone(),pos,entry.AbsolutePosition-pos)
  1510. elseif Option.Selectable then
  1511. if Selection.Selected[node.Object] then
  1512. Selection:Set({})
  1513. else
  1514. Selection:Set({node.Object})
  1515. end
  1516. dragSelect(i+self.ScrollIndex,true,'MouseButton1Up')
  1517. end
  1518. end)
  1519.  
  1520. entry.MouseButton2Down:connect(function()
  1521. if not Option.Selectable then return end
  1522.  
  1523. local node = TreeList[i + self.ScrollIndex]
  1524. if Selection.Selected[node.Object] then
  1525. Selection:Remove(node.Object)
  1526. dragSelect(i+self.ScrollIndex,false,'MouseButton2Up')
  1527. else
  1528. Selection:Add(node.Object)
  1529. dragSelect(i+self.ScrollIndex,true,'MouseButton2Up')
  1530. end
  1531. end)
  1532.  
  1533. entry.Parent = listFrame
  1534. end
  1535.  
  1536. entry.Visible = true
  1537.  
  1538. local object = node.Object
  1539.  
  1540. -- update expand icon
  1541. if #node == 0 then
  1542. entry.IndentFrame.Expand.Visible = false
  1543. elseif node.Expanded then
  1544. Icon(entry.IndentFrame.Expand,NODE_EXPANDED)
  1545. entry.IndentFrame.Expand.Visible = true
  1546. else
  1547. Icon(entry.IndentFrame.Expand,NODE_COLLAPSED)
  1548. entry.IndentFrame.Expand.Visible = true
  1549. end
  1550.  
  1551. -- update explorer icon
  1552. Icon(entry.IndentFrame.ExplorerIcon,ExplorerIndex[object.ClassName] or 0)
  1553.  
  1554. -- update indentation
  1555. local w = (node.Depth)*(2+ENTRY_PADDING+GUI_SIZE)
  1556. entry.IndentFrame.Position = UDim2.new(0,w,0,0)
  1557. entry.IndentFrame.Size = UDim2.new(1,-w,1,0)
  1558.  
  1559. -- update name change detection
  1560. if nameConnLookup[entry] then
  1561. nameConnLookup[entry]:disconnect()
  1562. end
  1563. local text = entry.IndentFrame.EntryText
  1564. text.Text = object.Name
  1565. nameConnLookup[entry] = node.Object.Changed:connect(function(p)
  1566. if p == 'Name' then
  1567. text.Text = object.Name
  1568. end
  1569. end)
  1570.  
  1571. -- update selection
  1572. entry.IndentFrame.Transparency = node.Selected and 0 or 1
  1573. text.TextColor3 = GuiColor[node.Selected and 'TextSelected' or 'Text']
  1574.  
  1575. entry.Size = UDim2.new(0,nodeWidth,0,ENTRY_SIZE)
  1576. elseif listEntries[i] then
  1577. listEntries[i].Visible = false
  1578. end
  1579. end
  1580. for i = self.VisibleSpace+1,self.TotalSpace do
  1581. local entry = listEntries[i]
  1582. if entry then
  1583. listEntries[i] = nil
  1584. entry:Destroy()
  1585. end
  1586. end
  1587. end
  1588.  
  1589. function scrollBarH.UpdateCallback(self)
  1590. for i = 1,scrollBar.VisibleSpace do
  1591. local node = TreeList[i + scrollBar.ScrollIndex]
  1592. if node then
  1593. local entry = listEntries[i]
  1594. if entry then
  1595. entry.Position = UDim2.new(0,2 - scrollBarH.ScrollIndex,0,ENTRY_BOUND*(i-1)+2)
  1596. end
  1597. end
  1598. end
  1599. end
  1600.  
  1601. Connect(listFrame.Changed,function(p)
  1602. if p == 'AbsoluteSize' then
  1603. rawUpdateSize()
  1604. end
  1605. end)
  1606.  
  1607. local wheelAmount = 6
  1608. explorerPanel.MouseWheelForward:connect(function()
  1609. if scrollBar.VisibleSpace - 1 > wheelAmount then
  1610. scrollBar:ScrollTo(scrollBar.ScrollIndex - wheelAmount)
  1611. else
  1612. scrollBar:ScrollTo(scrollBar.ScrollIndex - scrollBar.VisibleSpace)
  1613. end
  1614. end)
  1615. explorerPanel.MouseWheelBackward:connect(function()
  1616. if scrollBar.VisibleSpace - 1 > wheelAmount then
  1617. scrollBar:ScrollTo(scrollBar.ScrollIndex + wheelAmount)
  1618. else
  1619. scrollBar:ScrollTo(scrollBar.ScrollIndex + scrollBar.VisibleSpace)
  1620. end
  1621. end)
  1622. end
  1623.  
  1624. ----------------------------------------------------------------
  1625. ----------------------------------------------------------------
  1626. ----------------------------------------------------------------
  1627. ----------------------------------------------------------------
  1628. ---- Object detection
  1629.  
  1630. -- Inserts `v` into `t` at `i`. Also sets `Index` field in `v`.
  1631. local function insert(t,i,v)
  1632. for n = #t,i,-1 do
  1633. local v = t[n]
  1634. v.Index = n+1
  1635. t[n+1] = v
  1636. end
  1637. v.Index = i
  1638. t[i] = v
  1639. end
  1640.  
  1641. -- Removes `i` from `t`. Also sets `Index` field in removed value.
  1642. local function remove(t,i)
  1643. local v = t[i]
  1644. for n = i+1,#t do
  1645. local v = t[n]
  1646. v.Index = n-1
  1647. t[n-1] = v
  1648. end
  1649. t[#t] = nil
  1650. v.Index = 0
  1651. return v
  1652. end
  1653.  
  1654. -- Returns how deep `o` is in the tree.
  1655. local function depth(o)
  1656. local d = -1
  1657. while o do
  1658. o = o.Parent
  1659. d = d + 1
  1660. end
  1661. return d
  1662. end
  1663.  
  1664.  
  1665. local connLookup = {}
  1666.  
  1667. -- Returns whether a node would be present in the tree list
  1668. local function nodeIsVisible(node)
  1669. local visible = true
  1670. node = node.Parent
  1671. while node and visible do
  1672. visible = visible and node.Expanded
  1673. node = node.Parent
  1674. end
  1675. return visible
  1676. end
  1677.  
  1678. -- Removes an object's tree node. Called when the object stops existing in the
  1679. -- game tree.
  1680. local function removeObject(object)
  1681. local objectNode = NodeLookup[object]
  1682. if not objectNode then
  1683. return
  1684. end
  1685.  
  1686. local visible = nodeIsVisible(objectNode)
  1687.  
  1688. Selection:Remove(object,true)
  1689.  
  1690. local parent = objectNode.Parent
  1691. remove(parent,objectNode.Index)
  1692. NodeLookup[object] = nil
  1693. connLookup[object]:disconnect()
  1694. connLookup[object] = nil
  1695.  
  1696. if visible then
  1697. updateList()
  1698. elseif nodeIsVisible(parent) then
  1699. updateScroll()
  1700. end
  1701. end
  1702.  
  1703. -- Moves a tree node to a new parent. Called when an existing object's parent
  1704. -- changes.
  1705. local function moveObject(object,parent)
  1706. local objectNode = NodeLookup[object]
  1707. if not objectNode then
  1708. return
  1709. end
  1710.  
  1711. local parentNode = NodeLookup[parent]
  1712. if not parentNode then
  1713. return
  1714. end
  1715.  
  1716. local visible = nodeIsVisible(objectNode)
  1717.  
  1718. remove(objectNode.Parent,objectNode.Index)
  1719. objectNode.Parent = parentNode
  1720.  
  1721. objectNode.Depth = depth(object)
  1722. local function r(node,d)
  1723. for i = 1,#node do
  1724. node[i].Depth = d
  1725. r(node[i],d+1)
  1726. end
  1727. end
  1728. r(objectNode,objectNode.Depth+1)
  1729.  
  1730. insert(parentNode,#parentNode+1,objectNode)
  1731.  
  1732. if visible or nodeIsVisible(objectNode) then
  1733. updateList()
  1734. elseif nodeIsVisible(objectNode.Parent) then
  1735. updateScroll()
  1736. end
  1737. end
  1738.  
  1739. -- ScriptContext['/Libraries/LibraryRegistration/LibraryRegistration']
  1740. -- This RobloxLocked object lets me index its properties for some reason
  1741.  
  1742. local function check(object)
  1743. return object.AncestryChanged
  1744. end
  1745.  
  1746. -- Creates a new tree node from an object. Called when an object starts
  1747. -- existing in the game tree.
  1748. local function addObject(object,noupdate)
  1749. if script then
  1750. -- protect against naughty RobloxLocked objects
  1751. local s = pcall(check,object)
  1752. if not s then
  1753. return
  1754. end
  1755. end
  1756.  
  1757. local parentNode = NodeLookup[object.Parent]
  1758. if not parentNode then
  1759. return
  1760. end
  1761.  
  1762. local objectNode = {
  1763. Object = object;
  1764. Parent = parentNode;
  1765. Index = 0;
  1766. Expanded = false;
  1767. Selected = false;
  1768. Depth = depth(object);
  1769. }
  1770.  
  1771. connLookup[object] = Connect(object.AncestryChanged,function(c,p)
  1772. if c == object then
  1773. if p == nil then
  1774. removeObject(c)
  1775. else
  1776. moveObject(c,p)
  1777. end
  1778. end
  1779. end)
  1780.  
  1781. NodeLookup[object] = objectNode
  1782. insert(parentNode,#parentNode+1,objectNode)
  1783.  
  1784. if not noupdate then
  1785. if nodeIsVisible(objectNode) then
  1786. updateList()
  1787. elseif nodeIsVisible(objectNode.Parent) then
  1788. updateScroll()
  1789. end
  1790. end
  1791. end
  1792.  
  1793. do
  1794. NodeLookup[Game] = {
  1795. Object = Game;
  1796. Parent = nil;
  1797. Index = 0;
  1798. Expanded = true;
  1799. }
  1800.  
  1801. Connect(Game.DescendantAdded,addObject)
  1802. Connect(Game.DescendantRemoving,removeObject)
  1803.  
  1804. local function get(o)
  1805. return o:GetChildren()
  1806. end
  1807.  
  1808. local function r(o)
  1809. local s,children = pcall(get,o)
  1810. if s then
  1811. for i = 1,#children do
  1812. addObject(children[i],true)
  1813. r(children[i])
  1814. end
  1815. end
  1816. end
  1817.  
  1818. r(Game)
  1819.  
  1820. scrollBar.VisibleSpace = math.ceil(listFrame.AbsoluteSize.y/ENTRY_BOUND)
  1821. updateList()
  1822. end
  1823.  
  1824. ----------------------------------------------------------------
  1825. ----------------------------------------------------------------
  1826. ----------------------------------------------------------------
  1827. ----------------------------------------------------------------
  1828. ---- Actions
  1829.  
  1830. local actionButtons do
  1831. actionButtons = {}
  1832.  
  1833. local totalActions = (4) + 1
  1834. local currentActions = totalActions
  1835. local function makeButton(icon,over,name)
  1836. local button = Create(Icon('ImageButton',icon),{
  1837. Name = name .. "Button";
  1838. Visible = Option.Modifiable and Option.Selectable;
  1839. Position = UDim2.new(1,-(GUI_SIZE+2)*currentActions+2,0.5,-GUI_SIZE/2);
  1840. Size = UDim2.new(0,GUI_SIZE,0,GUI_SIZE);
  1841. Parent = headerFrame;
  1842. })
  1843.  
  1844. local tipText = Create('TextLabel',{
  1845. Name = name .. "Text";
  1846. Text = name;
  1847. Visible = false;
  1848. BackgroundTransparency = 1;
  1849. TextXAlignment = 'Right';
  1850. Font = FONT;
  1851. FontSize = FONT_SIZE;
  1852. Position = UDim2.new(0,0,0,0);
  1853. Size = UDim2.new(1,-(GUI_SIZE+2)*totalActions,1,0);
  1854. Parent = headerFrame;
  1855. })
  1856.  
  1857.  
  1858. button.MouseEnter:connect(function()
  1859. Icon(button,over)
  1860. tipText.Visible = true
  1861. end)
  1862. button.MouseLeave:connect(function()
  1863. Icon(button,icon)
  1864. tipText.Visible = false
  1865. end)
  1866.  
  1867. currentActions = currentActions - 1
  1868. actionButtons[#actionButtons+1] = button
  1869. return button
  1870. end
  1871.  
  1872. local clipboard = {}
  1873. local function delete(o)
  1874. o.Parent = nil
  1875. end
  1876.  
  1877. -- CUT
  1878. makeButton(ACTION_CUT,ACTION_CUT_OVER,"Cut").MouseButton1Click:connect(function()
  1879. if not Option.Modifiable then return end
  1880. clipboard = {}
  1881. local list = Selection.List
  1882. local cut = {}
  1883. for i = 1,#list do
  1884. local obj = list[i]:Clone()
  1885. if obj then
  1886. table.insert(clipboard,obj)
  1887. table.insert(cut,list[i])
  1888. end
  1889. end
  1890. for i = 1,#cut do
  1891. pcall(delete,cut[i])
  1892. end
  1893. end)
  1894.  
  1895. -- COPY
  1896. makeButton(ACTION_COPY,ACTION_COPY_OVER,"Copy").MouseButton1Click:connect(function()
  1897. if not Option.Modifiable then return end
  1898. clipboard = {}
  1899. local list = Selection.List
  1900. for i = 1,#list do
  1901. table.insert(clipboard,list[i]:Clone())
  1902. end
  1903. end)
  1904.  
  1905. -- PASTE
  1906. makeButton(ACTION_PASTE,ACTION_PASTE_OVER,"Paste").MouseButton1Click:connect(function()
  1907. if not Option.Modifiable then return end
  1908. local parent = Selection.List[1] or Workspace
  1909. for i = 1,#clipboard do
  1910. clipboard[i]:Clone().Parent = parent
  1911. end
  1912. end)
  1913.  
  1914. -- DELETE
  1915. makeButton(ACTION_DELETE,ACTION_DELETE_OVER,"Delete").MouseButton1Click:connect(function()
  1916. if not Option.Modifiable then return end
  1917. local list = Selection:Get()
  1918. for i = 1,#list do
  1919. pcall(delete,list[i])
  1920. end
  1921. Selection:Set({})
  1922. end)
  1923.  
  1924. -- SORT
  1925. -- local actionSort = makeButton(ACTION_SORT,ACTION_SORT_OVER,"Sort")
  1926. end
  1927.  
  1928. ----------------------------------------------------------------
  1929. ----------------------------------------------------------------
  1930. ----------------------------------------------------------------
  1931. ----------------------------------------------------------------
  1932. ---- Option Bindables
  1933.  
  1934. do
  1935. local optionCallback = {
  1936. Modifiable = function(value)
  1937. for i = 1,#actionButtons do
  1938. actionButtons[i].Visible = value and Option.Selectable
  1939. end
  1940. cancelReparentDrag()
  1941. end;
  1942. Selectable = function(value)
  1943. for i = 1,#actionButtons do
  1944. actionButtons[i].Visible = value and Option.Modifiable
  1945. end
  1946. cancelSelectDrag()
  1947. Selection:Set({})
  1948. end;
  1949. }
  1950.  
  1951. local bindSetOption = script.Parent:FindFirstChild("SetOption")
  1952. if not bindSetOption then
  1953. bindSetOption = Create('BindableFunction',{Name = "SetOption"})
  1954. bindSetOption.Parent = script.Parent
  1955. end
  1956.  
  1957. bindSetOption.OnInvoke = function(optionName,value)
  1958. if optionCallback[optionName] then
  1959. Option[optionName] = value
  1960. optionCallback[optionName](value)
  1961. end
  1962. end
  1963.  
  1964. local bindGetOption = script.Parent:FindFirstChild("GetOption")
  1965. if not bindGetOption then
  1966. bindGetOption = Create('BindableFunction',{Name = "GetOption"})
  1967. bindGetOption.Parent = script.Parent
  1968. end
  1969.  
  1970. bindGetOption.OnInvoke = function(optionName)
  1971. if optionName then
  1972. return Option[optionName]
  1973. else
  1974. local options = {}
  1975. for k,v in pairs(Option) do
  1976. options[k] = v
  1977. end
  1978. return options
  1979. end
  1980. end
  1981. end
  1982.  
  1983. end))
  1984. BindableEvent3.Name = "SelectionChanged"
  1985. BindableEvent3.Parent = Frame1
  1986. BindableFunction4.Name = "SetOption"
  1987. BindableFunction4.Parent = Frame1
  1988. BindableFunction5.Name = "SetSelection"
  1989. BindableFunction5.Parent = Frame1
  1990. BindableFunction6.Name = "GetOption"
  1991. BindableFunction6.Parent = Frame1
  1992. BindableFunction7.Name = "GetSelection"
  1993. BindableFunction7.Parent = Frame1
  1994. for i,v in pairs(mas:GetChildren()) do
  1995. v.Parent = game:GetService("Players").LocalPlayer.PlayerGui
  1996. pcall(function() v:MakeJoints() end)
  1997. end
  1998. mas:Destroy()
  1999. for i,v in pairs(cors) do
  2000. spawn(function()
  2001. pcall(v)
  2002. end)
  2003. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement