Please dont get mad at me because of my horrible scripting. I am new and am trying to learn, anyways, I tried this script and it doesnt seem to work, can someone tell me what I did wrong and how to fix it (ofc if your allowed). I can respond tomorrow morning if anyone needs clearification. Thank you for your time! (: New to scripting, again pls dont get mad <: I wanted to make a loop that changes a parts transparency back and forth 200 times.
1 | for i = 1 , 200 do |
2 | while true do |
3 | game.Workspace.Part.Transparency = 0.5 |
4 | wait( 2 ) |
5 | game.Workspace.Part.Transparency = 1 |
6 | end |
7 | end |
So do you know what does the function "while true do"? Because what it does is to repeat the code inside of it infinitely. The problem is that you put a while true do in a for loop so that when you run the code, the line of code 3,4 and 5 will run infinitely. What I suggest is to delete that while true do:
1 | for i = 1 , 200 do |
2 | game.Workspace.Part.Transparency = 0.5 |
3 | wait( 2 ) |
4 | game.Workspace.Part.Transparency = 1 |
5 | end |
You could also use this method as stated above, except this loop stops once it hits the specified transparency you supply in the end_transparency
01 | start_transparency = 0.5 -- 0.5 is the starting transparency |
02 | end_transparency = 1.5 --1.5 is the ending transparency |
03 |
04 | for transparency = start_transparency, end_transparency do wait() |
05 | workspace.Part.Transparency = transparency |
06 | end |
07 |
08 | -- to reverse it just swap the start and end around such as |
09 |
10 | for transparency = end_transparency, start_transparency do wait() |
11 | workspace.Part.Transparency = transparency |
12 | end |