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.
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.
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
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()
^ 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.
4 comments
The script you included starts from transparency 1 and goes to 0, the asker wants it to fade out
ill just replace the numbers
Although, this is a solution it is not the best solution. Use Tween because for loops are memory inefficient and time inefficient. Happy scripting.
look at the answer below, it uses tween