Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
1yz4 2
1 year ago
Edited 1 year ago

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.

0
sorry about that, I added a wait in the correct spot and my script should now work cmgtotalyawesome 1418 — 1y

3 answers

Log in to vote
0
Answered by
aviel101 165
1 year ago

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)
0
Works perfectly, thank you! 1yz4 2 — 1y
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. 1yz4 2 — 1y
0
change the `0.2 * i` to `0.5 + 0.1 * i`, it should work aviel101 165 — 1y
Ad
Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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.

0
The script works, but the model becomes fully transparent instantly. I'm trying to get it to gradually become transparent. 1yz4 2 — 1y
0
add a wait after the "parts[x].Transparency" AidanTES 36 — 1y
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. 1yz4 2 — 1y
Log in to vote
0
Answered by 1 year ago
-- "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

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 cmgtotalyawesome 1418 — 1y

Answer this question