How i can get Only Descendants

image

while wait(1) do
	print(script.Parent:GetDescendants())
end```

When I do this it gives me the Descendants and first children

Does this work?

local Parent = script.Parent
local Descendants = {}

for i,v in Parent:GetDescendants() do
if v.Parent ~= Parent then
table.insert(Descendants, v)
end
end

Sorry for the weird formatting

1 Like

since you seemingly only want values you can loop through children and put their value in a table.

local values={}
for _,v in script.Parent:GetChildren() do
local value=v:FindFirstChild("Value")
if value then
table.insert(values,value)
--or do values[v.Name]=value if you want to be able to know what it's parented to
end
end
1 Like
	for i,v in script.Parent:GetDescendants() do
		if v.Parent ~= script.Parent then
			--the Cood
		end
	end

this was fix my problem

2 Likes

Also, because you are trying to get value, you could do this:

for int, obj in script.Parent:GetDescendants() do
		if obj:IsA("NumberValue") then --change the NumberValue to any type of value or descendant you are looking for
			--the Code
		end
	end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.