Advertisement
psub_reborn

Child Viewer v1.01

Apr 6th, 2025 (edited)
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.25 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3.  
  4. local gui = Instance.new("ScreenGui", player.PlayerGui)
  5. gui.ResetOnSpawn = false
  6. gui.Name = "ChildViewer"
  7.  
  8. local box = Instance.new("SelectionBox", gui)
  9.  
  10. local frame = Instance.new("Frame", gui)
  11. frame.AnchorPoint = Vector2.new(0, 0.5)
  12. frame.Position = UDim2.new(0, 0, 0.5, 0)
  13. frame.Size = UDim2.new(0.25, 0, 0.65, 0)
  14. frame.BorderColor3 = Color3.new(0, 0, 0)
  15. frame.BackgroundColor3 = Color3.new(1, 1, 1)
  16. frame.Transparency = 0.5
  17. frame.Active = true
  18. frame.Draggable = true
  19.  
  20. local childrenFrame = Instance.new("ScrollingFrame", gui)
  21. childrenFrame.Visible = false
  22. childrenFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  23. childrenFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
  24. childrenFrame.Size = UDim2.new(0.4, 0, 0.7, 0)
  25. childrenFrame.BorderColor3 = Color3.new(0, 0, 0)
  26. childrenFrame.BackgroundColor3 = Color3.new(1, 1, 1)
  27. childrenFrame.Transparency = 0.5
  28. childrenFrame.CanvasSize = UDim2.new(0, 0, 100, 0)
  29. Instance.new("UIPadding", childrenFrame).PaddingTop = UDim.new(0, 25)
  30.  
  31. local listLay = Instance.new("UIListLayout", childrenFrame)
  32. listLay.Padding = UDim.new(0, 25)
  33. listLay.HorizontalAlignment = Enum.HorizontalAlignment.Center
  34.  
  35. local partName = Instance.new("TextLabel", frame)
  36. partName.BackgroundTransparency = 1
  37. partName.AnchorPoint = Vector2.new(0.5, 0)
  38. partName.Text = "No part selected"
  39. partName.TextColor3 = Color3.new(0, 0, 0)
  40. partName.TextScaled = true
  41. partName.Size = UDim2.new(0.9, 0, 0.1, 0)
  42. partName.Position = UDim2.new(0.5, 0, 0.1, 0)
  43.  
  44. local partParent = Instance.new("TextLabel", frame)
  45. partParent.BackgroundTransparency = 1
  46. partParent.AnchorPoint = Vector2.new(0, 0)
  47. partParent.Text = "No part selected"
  48. partParent.TextColor3 = Color3.new(0, 0, 0)
  49. partParent.TextScaled = true
  50. partParent.RichText = true
  51. partParent.Size = UDim2.new(0.9, 0, 0.1, 0)
  52. partParent.Position = UDim2.new(0.05, 0, 0.25, 0)
  53. partParent.TextXAlignment = Enum.TextXAlignment.Left
  54.  
  55. local partPos = Instance.new("TextLabel", frame)
  56. partPos.BackgroundTransparency = 1
  57. partPos.AnchorPoint = Vector2.new(0, 0)
  58. partPos.Text = "No part selected"
  59. partPos.TextColor3 = Color3.new(0, 0, 0)
  60. partPos.TextScaled = true
  61. partPos.RichText = true
  62. partPos.Size = UDim2.new(0.9, 0, 0.1, 0)
  63. partPos.Position = UDim2.new(0.05, 0, 0.4, 0)
  64. partPos.TextXAlignment = Enum.TextXAlignment.Left
  65.  
  66. local partSize = Instance.new("TextLabel", frame)
  67. partSize.BackgroundTransparency = 1
  68. partSize.AnchorPoint = Vector2.new(0, 0)
  69. partSize.Text = "No part selected"
  70. partSize.TextColor3 = Color3.new(0, 0, 0)
  71. partSize.TextScaled = true
  72. partSize.RichText = true
  73. partSize.Size = UDim2.new(0.9, 0, 0.1, 0)
  74. partSize.Position = UDim2.new(0.05, 0, 0.55, 0)
  75. partSize.TextXAlignment = Enum.TextXAlignment.Left
  76.  
  77. local tpPart = Instance.new("TextButton", frame)
  78. tpPart.BackgroundTransparency = 0.375
  79. tpPart.AnchorPoint = Vector2.new(0.5, 0)
  80. tpPart.Text = "Teleport to Part"
  81. tpPart.TextColor3 = Color3.new(0, 0, 0)
  82. tpPart.TextScaled = true
  83. tpPart.RichText = true
  84. tpPart.Size = UDim2.new(0.5, 0, 0.1, 0)
  85. tpPart.BorderColor3 = Color3.new(0, 0, 0)
  86. tpPart.BackgroundColor3 = Color3.new(1, 1, 1)
  87. tpPart.Position = UDim2.new(0.5, 0, 0.725, 0)
  88.  
  89. local partChildren = Instance.new("TextButton", frame)
  90. partChildren.BackgroundTransparency = 0.375
  91. partChildren.AnchorPoint = Vector2.new(0.5, 0)
  92. partChildren.Text = "View Descendants of Part"
  93. partChildren.TextColor3 = Color3.new(0, 0, 0)
  94. partChildren.TextScaled = true
  95. partChildren.RichText = true
  96. partChildren.Size = UDim2.new(0.5, 0, 0.1, 0)
  97. partChildren.BorderColor3 = Color3.new(0, 0, 0)
  98. partChildren.BackgroundColor3 = Color3.new(1, 1, 1)
  99. partChildren.Position = UDim2.new(0.5, 0, 0.85, 0)
  100.  
  101. local function get()
  102.     local ray = Ray.new(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 1000)
  103.     return workspace:FindPartOnRayWithIgnoreList(ray, { player.Character })
  104. end
  105.  
  106. local foundPart = false
  107. mouse.Button2Down:Connect(function()
  108.     local part, position = get()
  109.     if part then
  110.         local fullName = part:GetFullName()
  111.         local lowered = string.split(fullName, ".")
  112.         lowered[1] = string.lower(lowered[1])
  113.         lowered = table.concat(lowered, ".")
  114.        
  115.         foundPart = true
  116.         box.Adornee = part
  117.         partName.Text = `"{part.Name}"`
  118.         partParent.Text = `Parent: <b>{lowered}</b>`
  119.         partPos.Text = `Position: <b>{part.Position}</b>`
  120.         partSize.Text = `Size: <b>{part.Size}</b>`
  121.     else
  122.         foundPart = false
  123.         box.Adornee = nil
  124.         partName.Text = "No part selected"
  125.         partParent.Text = "No part selected"
  126.         partPos.Text = "No part selected"
  127.         partSize.Text = "No part selected"
  128.     end
  129. end)
  130.  
  131. local opened = false
  132. local function childrenViewer()
  133.     if foundPart then
  134.         opened = not opened
  135.         for i, v in pairs(childrenFrame:GetChildren()) do if v:IsA("TextLabel") then v:Destroy() end end
  136.         childrenFrame.Visible = opened
  137.  
  138.         local children = box.Adornee:GetDescendants()
  139.  
  140.         for i, v in pairs(children) do
  141.             local child = Instance.new("TextLabel", childrenFrame)
  142.             child.Size = UDim2.new(0.9, 0, 0, 50)
  143.             child.BorderColor3 = Color3.new(0, 0, 0)
  144.             child.BackgroundColor3 = Color3.new(1, 1, 1)
  145.             child.Transparency = 0.25
  146.             child.TextScaled = true
  147.             child.TextXAlignment = Enum.TextXAlignment.Left
  148.  
  149.             local fullName = v:GetFullName()
  150.             local lowered = string.split(fullName, ".")
  151.             lowered[1] = string.lower(lowered[1])
  152.             lowered = table.concat(lowered, ".")
  153.             child.Text = `{lowered} ({v.ClassName})`
  154.         end
  155.     else
  156.         game.StarterGui:SetCore("SendNotification", {
  157.             Title = "Error",
  158.             Text = "You have no part selected.",
  159.             Duration = 2
  160.         })
  161.     end
  162. end
  163.  
  164. local function tpToPart()
  165.     if foundPart then
  166.         local character = player.Character
  167.         local hrp = character:FindFirstChild("HumanoidRootPart")
  168.         if hrp then
  169.             hrp.CFrame = box.Adornee.CFrame
  170.         end
  171.     else
  172.         game.StarterGui:SetCore("SendNotification", {
  173.             Title = "Error",
  174.             Text = "You have no part selected.",
  175.             Duration = 2
  176.         })
  177.     end
  178. end
  179.  
  180. partChildren.MouseButton1Click:Connect(childrenViewer)
  181. tpPart.MouseButton1Click:Connect(tpToPart)
  182. game.UserInputService.InputBegan:Connect(function(input)
  183.     if input.KeyCode == Enum.KeyCode.T then
  184.         tpToPart()
  185.     end
  186. end)
  187.  
  188. task.wait(1)
  189. game.StarterGui:SetCore("SendNotification", {
  190.     Title = "Controls",
  191.     Text = "Right click on a part to see its info\nT to teleport to the selected part",
  192. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement