Slowly making npc transparent

I have been wondering, is there a way to change a npc’s transparency slowly from 0 to 1?
I know that if you want to change transparency of a npc, you would have to do

for i, v in pairs(npc:GetChildren())  do
	if v:IsA("BasePart") then
		v.Transparency = 1
	end
end

and if you want to change something’s transparency slowly, you would have to do this:

for loop = 0,1,0.1 do
	something.Transparency = loop
	wait(0.1)
end

Now the point is, if I insert the loop everytime it goes through a “BasePart”, then the whole npc won’t disappear slowly, instead, every body part’s transparency will slowly change to 1 ( Like first the head, then the arms, then the legs, and the torso etc ), but not changing as a whole.

Is there any way to change the transparency of a npc slowly from 0 to 1? Thanks

To do this you would need to use Tween Service read the topic linked below and if you have any questions reply below.

1 Like

I don’t really get how to do it after reading, could you please explain to me :sweat:

Local tweenservice = game:GetService("TweenService")

Local tweeninf = TweenInfo.new(1) -- this how i usually do

For i v in ipairs(npc:GetChildren()) do
       If v: IsA("Part") then
            Tweenservice:Create(v,tweeninf,{Transparency = 1}):Play() -- takes 3 argument(target , tweeninfo , {properties})
              
       end
       task.wait(1)
end
2 Likes