Forest Logo
search
package_2

Transparency

By @stratizverified

Roblox

Transparency

Sets the transparency of an instance and all of its descendants together, while remembering each object's original transparency.

On creation it caches the transparency properties of the target and its descendants. Set then scales every cached value between its original and fully transparent.

Usage

local Transparency = require(path.to.Transparency)

local transparency = Transparency.new(workspace.Model)

transparency:Set(0.5) -- half faded from the original values
transparency:Set(1)   -- fully transparent
transparency:Set(0)   -- back to the original values

transparency:Destroy()

Supported classes

Frame, ScrollingFrame, CanvasGroup, ImageLabel, ImageButton, TextLabel, TextButton, TextBox, ViewportFrame, UIStroke, Beam, Part, MeshPart, and ParticleEmitter. Other classes in the tree are left untouched.

A CanvasGroup is faded through GroupTransparency alone. Its descendants are not tracked, so objects added inside the group later still fade with it.

A ViewportFrame is faded through ImageTransparency, which covers the world it draws. Parts, beams and particle emitters inside a viewport are not tracked.

API

Transparency.new(targetObject, options)

Caches the transparency properties of the target and its descendants and returns a new object.

Pass { TrackNewDescendants = true } to keep the cache in step with the tree. A descendant added later is learned as it is when added and brought to the current transparency, so add it in its resting state. A descendant removed is put back to its defaults and forgotten, so it can come back later without a fade baked in.

Transparency:Set(transparency)

Applies a transparency from 0 to 1 across every cached object, where 0 keeps the original values and 1 is fully transparent.

Transparency:Exempt(exemptedObject)

Restores the object and its descendants to their original values and stops tracking them, so later Set calls no longer affect them. With TrackNewDescendants, anything added under the object later stays untracked too.

Transparency:UpdateDefaults(object, ignoreDescendants)

Reads the current transparency of the object as its new default. Pass true for ignoreDescendants to update only the object itself. An exempted object is tracked again.

Transparency:Destroy()

Clears the cache and stops tracking new descendants. Objects keep their current transparency.

Package Details

Install command (Click to copy)


Version

1.3.0

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.