I probably made no sense in the title, so I'll try to make it more clearer here. I have a fade script that fades text in and out,
for i = 1, 0, -0.1 do wait() brought.TextTransparency = i end
I was wondering if I can redo the for but instead of it going to 0 I want it to go to 1. Is there any way to do this in the same for loop or do I have to make multiple?
It’s the same in terms of runtime if you had two for loops though...
So I don’t see why you would need to.
Also you can manipulate how much you want i to increase by if you don’t include the increment. So you could just say i + .1 in the for loop or i -.1.
Or you could do it recursively which is the fun way
local function ForLoop ( i, ending, incrementer, numberOfTimesItRanBackAndForth) if i == 1 then incrementer = -.1 if numberOfTimesItRanBackAndForth > 0 then numberOfTimesItRanBackAndForth = numberOfTimesItRanBackAndForth + 1 end elseif i == 0 then Incrementer = .1 numberOfTimesItRanBackAndForth = numberOfTimesItRanBackAndForth + 1 end if numberOfTimesBackAndForth == 2 then return end wait() brought.TextTransparency = i i = i + incrementer return ForLoop(i, incrementer, numberOfTimesBackAndForth) end ForLoop(1, -.1, 0)
Look over it and you can understand what it does. You can also set the number of times you want it to go to 0 to 1 and 1 to 0. So if numberOfTimesBackAndForth == 4 it would have went from 1 to 0, 0 to 1, 1 to 0 and 0 to 1.
You can do the same thing I did here in a while loop but without returning. You just have to add if statments and break when it hits a certain amount of loops you want.
You can make another for loop and put your loop for it to repeat, this is my only way that i can think.... For example:
for i = 1,2 do for i = 1, 0, -0.1 do wait() brought.TextTransparency = i end end
Pretty simple
Hope that helped !
I think this is what you're trying to do:
for i = 1, 0, -0.1 do wait() brought.TextTransparency = i end for i = 0, 1, 0.1 do wait() brought.TextTransparency = i end