How to make all parts change transparency at the same time?

Snippet of the script I am using to make the parts appear:
for i,v in pairs(Mystand:GetChildren()) do

		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then

			for count=1,0,-.1 do

				v.Transparency = count
				wait(.1)

			end

		end

	end

What happens:
https://gyazo.com/87485ba7d8598b1e695125bc7e166e4b

What do I do to make them all change transparency at the same time?

1 Like

you can make a new thread for each part. save all the threads then yeild them after.

1 Like

Coroutine it

for _, part in pairs(Mystand:GetChildren()) do
	if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
		coroutine.wrap(function()
			for count=1,0,-.1 do
				part.Transparency = count
				wait(.1)
			end
		end)()
	end
end
3 Likes

In addition to what the others have said, I recommend using TweenService as its purpose is to smoothly transition from one value to the next whereas using a loop is going to be a bit choppy. Also no need to create multiple threads (unless waiting for the .Completed event) as creating and playing the tween doesn’t yield the thread.

local tweenService = game:GetService('TweenService')
for i,v in pairs(Mystand:GetChildren()) do
    if v:IsA('BasePart') and v.Name ~= 'HumanoidRootPart' then
        tweenService:Create(v, TweenInfo.new(1), {Transparency = 0}):Play()
    end
end

lua threads aren’t really real threads. they are just separate environments for code to run. unless there is 1 million parts then you don’t really need to worry about the loop being choppy.

I know, I meant if you use tween service you won’t have to create multiple threads.

tween service does the same thing most likely.

1 Like