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

How to locate a part using a variable?

Asked by 3 years ago

Probably some silly mistake. The error code is Children is not a valid member of model

Children = script.Parent.Model:GetChildren()
script.Parent.Model.Children.Transparency = Variable

Thats just my problem but if the entire code is necessary here it is

Children = script.Parent.Model:GetChildren()
Variable = 0
Des = 0.01
OrDes = Des

function ftrancparency ()
    Variable = Variable + Des
    script.Parent.Model.Children.Transparency = Variable
end

while true do
    wait()

    ftrancparency()

    if Variable >= 1 then
        script.Parent.Model.Children.CanCollide = false
        wait (5)
        Des = -OrDes
    end

    if Variable <= 0 then
        script.Parent.Model.Children.CanCollide = true
        wait (10)
        Des = OrDes
    end

end

1 answer

Log in to vote
0
Answered by 3 years ago

Children returns a table/list/array of all descendants of "Model". You can't set a table's transparency, so you have to cycle through the list.

for i, v in pairs(script.Parent.Model:GetChildren()) do
    v.Transparency = Variable;
end
0
I dont really understand, but it worked. Thanks! wegetab 9 — 3y
0
If you want to try and think of it in a simplified way, GetChildren() gives you a list of everything inside the object (in this case, the model). You don't want to set the list's transparency, right? You want all of the children's transparency. So, you use a modified for loop to cycle through all of the object's children and change it's transparency. Loughdough 291 — 3y
Ad

Answer this question