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

How to slowly fade out a model?

Asked by 4 years ago

I'm trying to use a loop to slowly increase a model's transparency. How would I go about doing that?

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
local FadeModel_Out = function(ModelEntity, Speed)
   -- Put your supported Instance's that have Transparency property
    local SupportedTypes = {
     'Part';
    } 

    if ModelEntity:IsA("Model") then
        local Entities = ModelEntity:GetDescendants()
        for _,OBJ in next, Entities do
            for _,Type in next, SupportedTypes do
                if OBJ:IsA(Type) then
                spawn(function()
                  repeat
                    OBJ.Transparency = OBJ.Transparency + 0.1
                    wait(Speed)
                  until OBJ.Transparency == 1
                  end)
                end
            end
        end
    end
end

FadeModel_Out(workspace.Model, .01)
-- Arguement[1] Is your model directory path.
-- Arguement[2] Is your speed you want it to fade at.

I hope this helps your needs!

0
Wow. This is actually pretty clever. I thought I had to use a 'for' loop on all the parts of a model, but of course it could be a lot of parts. I might use this one day! Thanks! Sensei_Developer 298 — 4y
0
While I'm glad you help people, please don't spoonfeed code like you did here since people don't learn from this. poke7667 142 — 4y
0
Thank you for the help but I don't really understand how this works. Do I have to set a variable for "Speed"? EricTheCartRider43 2 — 4y
Ad

Answer this question