Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Make all parts in a model transparent at once instead of one at a time?

https://i.gyazo.com/d5ecd8aa50f846c9cff40b9aecf21ba6.gif

My script how it currently is:

-- "Fade" is the brick that triggers the transparency when stepped on.
-- "Robloxian" is the model.
local invis = true

game.Workspace.Fade.Touched:Connect(function(hit)
	if not invis then return end
	if not hit.Parent:FindFirstChild("Humanoid") then return end
	invis = false
	for k2,v2 in pairs(game.Workspace.Robloxian:GetDescendants()) do
		if v2:IsA("BasePart") then
			v2.Transparency = 0.2
			wait()
			v2.Transparency = 0.4
			wait()
			v2.Transparency = 0.6
			wait()
			v2.Transparency = 0.8
			wait()
			v2.Transparency = 1
		end
	end
end)

How do you make the decals transparent as well? I've always had issues with decals and transparency.

1 comment

0

sorry about that, I added a wait in the correct spot and my script should now work

3 answers

✓ Accepted answer

i edited cmgtotalyawesome's script a bit, it should be working

local invis = true
local parts = {}
workspace.Fade.Touched:Connect(function(hit)
	if not invis then return end
	if not hit.Parent:FindFirstChild("Humanoid") then return end
	invis = false
	for k2,v2 in pairs(game.Workspace.Robloxian:GetDescendants()) do
		if v2:IsA("BasePart") or v2:IsA("Decal") and v2.Transparency ~= 1 then
			table.insert(parts, v2)
		end
	end
	
	for i = 1, 5 do
		wait(0.2)
		for x = 1, #parts do
			parts[x].Transparency = 0.2 * i
		end		
	end
end)

3 comments

0

Works perfectly, thank you!

0

I do have a question though, how would I make the transparency start at 0.5? Because let's say the model is already half transparent, and if I step on the brick it becomes fully visible for a moment before becoming completely transparent.

0

change the 0.2 * i to 0.5 + 0.1 * i, it should work

What I would do to accomplish this is add every basepart and decal to a table and then run a loop like so:

-- "Fade" is the brick that triggers the transparency when stepped on.
-- "Robloxian" is the model.
local invis = true
local parts = {}

game.Workspace.Fade.Touched:Connect(function(hit)
    if not invis then return end
    if not hit.Parent:FindFirstChild("Humanoid") then return end
    invis = false
    for k2,v2 in pairs(game.Workspace.Robloxian:GetDescendants()) do
        if v2:IsA("BasePart") or v2:IsA("Decal") then
            table.insert(parts, #parts + 1)
        end
    end

    for i = 1, 5 do
	wait(--[[however long you wanna wait]])
        for x = 1, #parts do
            parts[x].Transparency = .2 * i
        end
    end
end)

I'm not sure if this will work as I don't really have access to studio right now, however if it does error leave the error as a comment and I'll fix it as soon as I can.

3 comments

0

The script works, but the model becomes fully transparent instantly. I'm trying to get it to gradually become transparent.

0

add a wait after the "parts[x].Transparency"

0

Did that, but that only makes the parts disappear one at a time instead of all at once. The parts don't gradually turn transparent either, they immediately do.

-- "Fade" is the brick that triggers the transparency when stepped on.
-- "Robloxian" is the model.
local invis = true
local parts = {}

game.Workspace.Fade.Touched:Connect(function(hit)
    if not invis then return end
    if not hit.Parent:FindFirstChild("Humanoid") then return end
    invis = false
    for k2,v2 in pairs(game.Workspace.Robloxian:GetDescendants()) do
        if v2:IsA("BasePart") or v2:IsA("Decal") then
            table.insert(parts, #parts + 1)
        end
    end

    for i = 1, 5 do
        for x = 1, #parts do
            parts[x].Transparency -= 0.1
	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
	    	    wait(0.3)
	    parts[x].Transparency -= 0.1
        end
    end
end)

I am not sure if this will work but you can try

1 comment

0

close but you don't need all the wait(.3)s because he wants it to look like the whole model is changing at once. Just add a wait(.3) in the initial for loop and also change every "-=" to "+= because he wanted it to be visible and not transparent

This discussion is preserved as it was. New answers, comments, and votes are closed.