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

error trying to change transparency with a GetChildren() value?

Asked by 5 years ago
wait(2)

local children = script.Parent:GetChildren()

for i = 1, #children do
allstuff1 = children[i]
    allstuff1.Transparency = 0.7
end
wait(0.1)
for i = 1, #children do
allstuff1 = children[i]
    allstuff1.Transparency = 0.6
end
wait(0.1)
for i = 1, #children do
allstuff1 = children[i]
    allstuff1.Transparency = 0.4
end
wait(0.1)
for i = 1, #children do
allstuff1 = children[i]
    allstuff1.Transparency = 0.1
end

im trying to change a group of parts transparency in stages, Im getting an error at line 7 saying: (transparency is not a valid member of script)

0
Have you tried checking whether it was a part or not via `IsA`? `if Obj:IsA('BasePart') then` TheeDeathCaster 2368 — 5y
0
I think I see the problem, I was getting all the children from the model including the script itself, just another thing right under my nose :/ mantorok4866 201 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You need to add a check.

for i = 1, #children do
if not i:IsA("Part") then return end--It checks if the object is a part and if not then it stops the current loop
allstuff1 = children[i]
allstuff1.Transparency = 0.7
end
Ad

Answer this question