Hello everyone, having a problem with my script, for whatever reason the loop only runs once, here is my code:
01 | while true do |
02 |
03 |
04 | local SoundPlay = math.random( 1 , 3 ) |
05 | local Time = math.random( 3 , 5 ) |
06 |
07 | wait(Time) |
08 | if SoundPlay = = 1 then |
09 | script.Parent.Sound 1 :Play() |
10 | end |
11 | wait(Time) |
12 | if SoundPlay = = 2 then |
13 | script.Parent.Sound 2 :Play() |
14 | end |
15 | wait(Time) |
16 | if SoundPlay = = 3 then |
17 | script.Parent.Sound 3 :Play() |
18 | end |
19 |
20 | end |
After the loop runs once, it doest play again, is there a reason for this?
I found out your mistake or error. From what I see in your script it doesn't have "wait" in the script, without wait in while true do it only works once, I made this mistake once too
01 | while true do |
02 | local SoundPlay = math.random( 1 , 3 ) |
03 | local Time = math.random( 3 , 5 ) |
04 | wait(Time) |
05 | if SoundPlay = = 1 then |
06 | script.Parent.Sound 1 :Play() |
07 | wait(insert seconds) |
08 | end |
09 | wait(Time) |
10 | if SoundPlay = = 2 then |
11 | script.Parent.Sound 2 :Play() |
12 | wait(insert seconds) |
13 | end |
14 | wait(Time) |
15 | if SoundPlay = = 3 then |
16 | script.Parent.Sound 3 :Play() |
17 | wait(insert seconds) |
18 | end |
19 | end |