I have the part were the transparency changes but I haven't scripted in a while and so I don't know what to do next..
01 | local function Close(Blib 1 ) |
02 | Blib 1. Transparency = . 2 |
03 | wait( 2 ) |
04 | Blib 1. Transparency = . 6 |
05 | wait( 2 ) |
06 | Blib 1. Transparency = . 8 |
07 | wait( 2 ) |
08 | Blib 1. Transparency = 1 |
09 |
10 | end |
11 |
12 |
13 | local function Open(Blib 1 ) |
14 | Blib 1. Transparency = . 8 |
15 | wait( 2 ) |
There are many ways to achieve this, but I will highlight only the most efficient way.
Firstly, you could implement a while loop with wait(20)
to improve the efficiency of the code.
1 | while wait( 120 ) do |
2 | end ; |
Next, we can use a boolean to store the status of the door.
1 | local open = true ; |
2 | while wait( 120 ) do |
3 | open = not (open); |
4 | end ; |
Now, we will use the and / or operators to determine which function to run.
1 | local open = true ; |
2 | while wait( 120 ) do |
3 | open = not (open); |
4 | local run = (open) and Open or Close; |
5 | run(workspace.Part); -- chance to what Blib1 should be. |
6 | end ; |
NOTE: This was written for use with your current functions.
Use a while
loop to continuously loop it:
1 | while true do |
2 | wait( 120 ) |
3 | end |
While
Loop Composition:
1 | while (argument) do |
2 | wait(WaitTime) |
3 | end |
Perhaps use a for
loop to script more efficiently in place of your functions :
1 | for i = 1 , 5 do |
2 | script.Parent.Transparency = script.Parent.Transparency + . 2 |
3 | wait( 2 ) |
4 | end |
5 | wait( 2 ) |
6 | for i = 1 , 5 do |
7 | script.Parent.Transparency = script.Parent.Transparency - . 2 |
8 | wait( 2 ) |
9 | end |
For
Loop Composition:
1 | for (variable) = (start number), ( end number), (increment (default = 1 )) do |
2 | wait(WaitTime) |
3 | end |