Why won't this script let my Frame called "Effect" become visible when it's parent has a TextTransparency equals to 0?
When v.TextTransparency is equal to 0, it's descendant named "Effect" should become visible, but it won't. Why?
Everything other than it's descendant named "effect" shows up like it is supposed to.
Here the part of my script that runs this, the function is called in a different part of the script.
function ShowPlayAndOptions() for i,v in pairs(Welcome:GetChildren()) do if v.Name == "Play" or v.Name == "Options" or v.Name == "Credits" then v.Visible = true for i = 1,0,-0.1 do v.TextTransparency = i wait() if v.TextTransparency == 0 then v:FindFirstChild("Effect").Visible = true end end end end end
It is because :GetChildren() does not get descendants of the object. :GetDescendants basically work like this.
function GetDescendants(object,stuff) local stuff = stuff or {} for _, object in pairs(object:GetChildren()) do table.insert(stuff, object) for _, object in pairs(GetDescendants(object, stuff) do --using a little bit of recursion table.insert(stuff, object) end end return stuff end
For example, say if you were looking at objects in StarterGui. :GetChildren will only get a table of things that is directly parented to StarterGui, as :GetDescendants gets a table of items parented to StarterGui, children of StarterGui, children of children of StarterGui, etc.
Hope this helps!