Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this false condition not get skipped even though FindFirstChild is used?

Asked by 1 year ago
local quantifier = AF[al.Text].TextureSections

if quantifier:FindFirstChild(tsb.Name) then
    continue
else
    local linkedto = Instance.new("ObjectValue")
    linkedto.Name = "LinkedTo"
    linkedto.Value = AF[al.Text].TextureSections:FindFirstChildOfClass("StringValue").Subsections[tsb.Name].Parent.Parent
    linkedto.Parent = tsb
end

The code below local quantifier is in a loop, so continue does not cause the error. Strings in place of object children, for example AF[al.Text] or Subsections[tsb.Name], also do not cause any errors, as other parts of the script have the same text and work perfectly.

Now, the code, into a table, assembles StringValues with names of accessories from the folder TextureSections. Some StringValues have no children, and others are names of children of accessories. The first part of the if statement checks if the accessory name is in TextureSections, and if not (making it a child of an a StringValue), it continues to the next part of the loop. The only immediate child of TextureSections is named Example, and when tsb.Name = "Example", the if statement is /supposed to/ continue to the next value in the table. However, it /doesn't do this/ and errors with "Subsections is not a valid member of StringValue "ReplicatedStorage.AccessoriesFolder.Black Iron Fiery Horns.TextureSections.Example"".

When I check if something exists using FindFirstChild in an if statement in a different part of the script or in another script, the if statement executes as intended. I tried using a different method by making a variable out of the entire path, local quantifier = AF[al.Text].TextureSections:FindFirstChild(tsb.Name) and writing if quantifier then ... end, which also works when I test it in a different script.

I do not know why FindFirstChild is not working now. Help and insights are appreciated.

Answer this question