Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Anyone knows a way to make a part slowly fade out?

I was wondering if there is a way to mak a part fade out without doing like

part.transparency = 0.6

wait(0,5)

part.transparency = 0.5

wait(0,5)

part.transparency = 0.4

etc.

2 answers

For loops. If you don't know what loops are, they are basically things that repeat over and over (with a condition.) A for loop repeats for how many times you want it to. The 1st parameter (i) is the start, the 2nd the end, and the 3rd is how many times you want it to repeat.

local part = workspace.Part
for i = 1, 0, -0.1 do
	part.Transparency = i
	wait(0.5)
end

4 comments

1

The script you included starts from transparency 1 and goes to 0, the asker wants it to fade out

0

ill just replace the numbers

0

Although, this is a solution it is not the best solution. Use Tween because for loops are memory inefficient and time inefficient. Happy scripting.

0

look at the answer below, it uses tween

This is possible, using TweenService and it will be a hundred times smoother. Insert a server script in the part and write:

wait(10) --Get close to the part and see it start to disappear after 10 seconds

local TS = game:GetService("TweenService")

Time = 4 --The number of time it takes to fade out

local Goal = {Transparency = 1}

local Info = TweenInfo.new(Time,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)

local Tween = TS:Create(script.Parent, Info, Goal)
Tween:Play()

1 comment

0

^ I agree with Shounak123. For loops take up memory and efficiency. Iteration is space inefficient and time inefficient. Using a for loop will make your game slower.

This discussion is preserved as it was. New answers, comments, and votes are closed.