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

How to fade a Union within a group?

Asked by 6 years ago

Hello,

So I have some unions in a model and I need them to fade on and off. I know I would have to use a loop but how would I go about doing that. There are multiple unions within the model so they all need to fade.

Thanks.

Anthony

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
6 years ago
Edited 6 years ago

Because your model consists of separate unions, it would be best to iterate through all the parts and fade them each using TweenService. You can use the function GetDescendants to get all instances of a group. Then, check to see if the instance is a part. Then you initialize a tween on the instance. In order to initialize a tween, you must specify an instance to perform on, a TweenInfo instance, and a table containing all the properties to be tweened. All of this would look something like this:

local TweenService = game:GetService("TweenService")

function fade(model , transparency , fadeTime)
    local descendants = model:GetDescendants()
    for i , v in pairs(descendants) do --iterate through descendants
        if v:IsA("BasePart") then
            local info = TweenInfo.new(fadeTime)
            local goal = {Transparency = transparency}
            local tween = TweenService:Create(v , info , goal)
            tween:Play() --start the tween
        end
    end
end

Read more about TweenService here:

http://wiki.roblox.com/index.php?title=API:Class/TweenService

Ad

Answer this question