Hi all,
I was just curious if there was a way for v to access the child of an object. The code I provided below obviously doesn’t work, but I’m sure you can see what I’m going for here. So my main question is: Is there any way for me to get this code to work other than having to manually create if statements for all values of v? Thanks
for i,v in pairs(copy.Connectors:GetChildren()) do
copy.Connectors.v.Depth.Value = copy.Connectors.v.Depth.Value + 1
end
I don’t understand. Are you trying to get a child within copy.Connectors that has the same name as v?
Wouldn’t that be a little redundant? Just use v???
for i,v in pairs(copy.Connectors:GetChildren()) do
local Depth = copy.Connectors:FindFirstChild(v.Name)
Depth.Value += 1
end
pairs does not list out objects in order, because a dictionary has no ‘correct’ order. The only way to parse a ‘table’ “in order” is by passing an array using ipairs. Using pairs otherwise does not guarantee that the table is parsed in the order that the developer writes it.