How to make a smooth transparency fade (with parts)

  1. What is the issue?

as you can see here there a red button but, there’s also glass, now what I want is a smooth transparency fade, I already have a script to when you break it the only thing I can’t figure out is how to make it smooth (meaning when you break the glass it will reaper in a smooth transparency way.) something like that, btw if your wondering what the glass transparency it’s 0.75 so you can see the button

  1. What solutions have you tried so far? yes but never found my asnwer
local GlassTrans = script.Parent
	script.Parent.Position =, 140.7, 2)
	script.Parent.ClickDetector.MaxActivationDistance = 0
	script.Parent.Position =, 141.2, 2)
	GlassTrans.Transparency = 1
	while true do
		GlassTrans.Transparency = script.Parent.Transparency > 0.01 --I have also try
--using a + - > < but it sometimes seems to either it shows numbers going high up to
--like (1.50) (3.23) or even higher (10.45) which idk why it dose that as it shows it
--invisible or, it puts the transparency 0
		print("it's doing it")
		if script.Parent.Transparency == 0.75 then
			script.Parent.ClickDetector.MaxActivationDistance = 10
			print("it broke out")
			print("might have ended")

do not write entire scripts or design entire systems for you

while item.Transparency > 0 do
    item.Transparency -= 0.05 -- The greater this number, the less it takes to fade item
    wait(0.1) -- The the lower the number in wait(), the less time it takes to fade item

With the above, I’d recommend you keep the num in "item.Transparency -= num relatively small (like 0.05 or whatever works) and adjust the parameter of wait(). This way it fades in more finite adjustments, not in choppy “bulks” at a time.


I would use TweenService to get the smooth transparency fade done.

don’t really use TweenService and plus can it really do that?

TweenService would work, but for a simple fade you could just do this:

Yeah. I think the code should look like this

local TweenService = game:GetService("Tween Service")

local tween = TweenService:Create(object, of time) , {Transparency = 0.75})

ok I see but I tried his code and it works out short and easy while this piece of code looks a little long I prefer the other code but thanks you.