I have 4 parts which are labeled in myTable. I'm trying to make them go up 0.1 every 0.2 seconds. Then I want my script to detect that a part has hit Transparency 1 and break it's loop and continue on to my next statement. This will basically do the same but opposite. (Starting from 1, it'll go down 0.1 every 0.2 seconds)
myTable = {game.Workspace.one,game.Workspace.two,game.Workspace.three,game.Workspace.four} while true do for i,v in pairs (myTable) do v.Transparency = v.Transparency + 0.1 wait(0.2) if v.Transparency == 1 then break end if v.Transparency == 1 then for i,v in pairs (myTable) do v.Transparency = v.Transparency - 0.1 wait(0.2) end end end end
Also, how would I make this stop at 0 transparency and do +0.1 and repeat this over and over? I can't figure it out. Do I need a whole new code?
The easiest way to accomplish this is to just use a numeric for loop. This will allow us to easily change the transparency and have no need for lots of if
statements or break
s.
--Invisible for i = 0, 1, 0.1 do wait(0.2) for _,v in pairs(myTable) do v.Transparency = i end end --Visible for i = 1, 0, -0.1 do wait(0.2) for _,v in pairs(myTable) do v.Transparency = i end end