For Count question

I’m trying to make a Count to fade a Part/GUI transparency. Howevar, I can’t figure out how to set it back to 0.

for Count = 1, 10 do
Part.Transparency = Count / 10 -- this will go from 0 to 1
task.wait(0.1)

To simplify, I wanted to make those script go from 1 to 0

Just have an if statement where when It reaches the number you want set it back to 0

1 Like

Add a third part to the for loop that goes -0.1 or whatever you need.
Example:

for i = 1,-5,-1 do
print(i)
end
1 Like
for Count = 10, 0, -1 do
Part.Transparency = Count/10
task.wait(0.1)
end
1 Like

The basic syntax includes a control variable , a start value, an end value, and an optional increment value.
Code Sample -

for i = 10 , 1 , -1 do
    -- code 
end

If the incrementation value is not defined it will be +1 by default.
I assume you know but yet , Roblox provides the documentation about almost every Development related matter from Luau syntax to all about Instances. Thus that is the best place to learn from or when you are confused.
Link:
Lua Loops

1 Like

Thank for all the reply!
I found out the solution, thank!

1 Like