How do I change the transparency of all children in a model all at once, instead of one by one?

For some reason, it fades the transparency 1 by 1 to 0. I want it to be all at once, but I don’t know what I’m doing wrong.

What it looks like: https://gyazo.com/3422da92089a4e5f4b5c8b87c6510afb

for _,v in pairs(Mystand:GetDescendants()) do
if v:IsA(“BasePart”) then
for f = 1,0,-0.5 do
wait()
v.Transparency = f
end
end
end

You should just swap the two and it would work correctly:

local MyStand = ...
for f=1,0,-0.5 do
  for i,v in pairs(MyStand:GetDescendants()) do
    if v:IsA('BasePart') then
      v.Transparency = f
    end
  end
  wait()
end

Hm, I’ve noticed that looping transparency can be laggy sometimes. Is it possible to tween the transparency? I already have the tween arguments set up, but how do I get the whole model as one variable?

local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(1) -- Time to tween
local MyStand = ...

for i,v in pairs(MyStand:GetDescendants()) do
  if v:IsA('BasePart') then
      TweenService:Create(v, TweenInfo, {Transparency = 1})
  end
end
2 Likes

@Legoracer didnt play the tween

TweenService:Create(v, TweenInfo, {Transparency = 1}):Play()

And no you cant Tween a model at once but if you do the for loop it actually wouldnt be noticable.

1 Like

Thanks for noticing that, I type most stuff in forum editor so its hard to see everything. :slight_smile:

1 Like

Wrapping it in a Spawn function should work fine

for _,v in pairs(Mystand:GetDescendants()) do
if v:IsA(“BasePart”) then
spawn(function()
for f = 1,0,-0.5 do
wait()
v.Transparency = f
end
end)
end
end

Using coroutine.create() is better than spawn because like @Kullaske said

spawn is delayed.

1 Like

It works fine, but how do I ignore the HumanoidRootPart? I want it to be invisible at all times.

I would suggest you using a function for the fading part

I already have the transparency tween working fine and smoothly, I just need to know how to ignore the HumanoidRootPart to stay invisible at all times.

Name the part the same thing and check if their names is that name

Yeah but if I do that, then that’d mean I would have to rename the limbs too and that would break the whole dummy

HumanoidRootPart is normally marked as a PrimaryPart or the RootPart property of the Humanoid.

You can also just iterate and ignore invisible parts since HumanoidRootPart is already transparent.

It doesn’t work, the transparency is still at 0.

I’m not sure how to ignore invisible parts, how would I go about it?

Ignore it when tweening transparency to 0. To ignore invisible parts you just check if part.Transparency == 1

So like this?:

if v:IsA(‘BasePart’) or v:IsA(‘Decal’) and v.Transparency == 1 then

Why the and? Now you are only using invisible parts.

Oh I thought you said to check if part.Transparency == 1, so just put an and there. I’m not sure what else to do.