Make every part in a model become transparent at the same time

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make every part inside of a model become transparent at the same time (making the transparency go up, not instant)

  2. What is the issue? Include screenshots / videos if possible!
    When I’m trying to make every part in a model transparent at the same time it either is instant or one at a time

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    A few different kinds of loops, all of them made it either instantly disappear or did it one at a time. (I looked on the Developer hub and elsewhere)

dummyHumanoid.Died:Connect(function()
	for _, part in ipairs(dummyHumanoid.Parent:GetDescendants()) do
		if part:IsA("BasePart") then
			if part.Transparency==0 then
				for transparency=0,1,0.1 do
					part.Transparency=transparency
					wait()
				end
			else
				part:Destroy()
			end
		else
			part:Destroy()
		end
	end
end)

Try this:

dummyHumanoid.Died:Connect(function()
	for _, part in ipairs(dummyHumanoid.Parent:GetDescendants()) do
		if part:IsA("BasePart") then
			if part.Transparency==0 then
                task.spawn(function()
				    for transparency=0,1,0.1 do
					    part.Transparency=transparency
					    task.wait()
				    end
                end)
			else
				part:Destroy()
			end
		else
			part:Destroy()
		end
	end
end)

The only thing I changed was I spawned a new thread for the for loop so it doesn’t pause the rest

1 Like

Since you’re doing this, I suggest replacing this with:

game:GetService("TweenService"):Create(part, TweenInfo.new(0.1), {Transparency = 1}):Play()

This way, you don’t need to spawn any tasks or create any coroutines.

2 Likes

Thanks, I used that code and made some edits to mine and it worked

dummyHumanoid.Died:Connect(function()
	for _, part in ipairs(dummyHumanoid.Parent:GetDescendants()) do
		if part:IsA("BasePart") then
			if part.Transparency==0 then
				game:GetService("TweenService"):Create(part, TweenInfo.new(3), {Transparency = 1}):Play()
			end
		end
	end
end)

your code is individually changing the transparency of each part, then moving to the next part when the current part is fully transparent. what you should do is loop through all parts 10 times and change their transparency once in each loop, instead of every part once and looping through that part’s transparency 10 times

1 Like