I have this siren that I want to be looped, But after I loop it I want it to stop playing. Any idea how to do this?
There are many different loops you could use for this or methods
For
This repeats a block of code x amount of times
for i = 1,10 do print'dog' wait(2) end
this will print dog 10 times with a 2 second delay
you could also enter a 3rd variable that defines how it counts
for i = 10,1,-1 do print(i) wait(2) end
this will count from 10 to 1(repeats 10 times) and print the number it is on Example output
10 9 8 7 6 5 4 3 2 1
While
This loop will be active while the statement you enter is true
while true do print("a big dog") end
however this will repeat forever with no delay so there are 2 ways around this
OPTION 1
local x = 1 while wait(1) do if x < 10 do print(x) x = x + 1 end end
OPTION 2
local x = 1 while x < 10 do print(x) x = x + 1 end