SelectionBox in Folders

Good morning / Good evening,

  • Is this script better than placing Selection Boxes on each Parts ?

  • GetDescendants() and GetChildren() What is the difference ?

  • Does creating spaces in my codes like :

for i, d in pairs(d) do
-- spaces 1
-- spaces 2
-- ...
if d:IsA(y) do
--...

affect reading speed and performance?

My scrpit for the Boxes :

-- Variable
local descendants = game.Workspace.Folder1:GetDescendants()
-- Selection
for index, descendant in pairs(descendants) do
	if descendant:IsA("BasePart") then
		-- Properties
		local selectionBox = Instance.new("SelectionBox")
		selectionBox.Adornee = descendant
		selectionBox.Color3 = Color3.new(0, 0, 0)
		selectionBox.LineThickness = 0.05
		selectionBox.Parent = descendant
	end
end

I’m a beginner I may have made mistakes. Thx for your help :slight_smile:

Hi there :heart: Here to answer your questions.

GetChildren gets every child of a specific object. GetDescendants gets the children of the object and the children of those children. For example:
image

GetChildren would return hi and ok. GetDescendants would return hi, ok, and bye.

The script for the SelectionBoxes should work just fine.

And finally, adding comments does not effect the script whatsoever.


Hope I answered all your questions!

1 Like

Well that’s great. Everything is clear ! Tysm :smiley: