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
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