At the first line it just say "Game script timeout" in output.
1 | if not sound.IsPlaying then |
2 | setSong() |
3 | sound:Play() |
4 | end |
I hope one of you guys can help me. - Toby
This is because while
loops run very fast. In fact, all loops run at high speeds, and for that require a cooldown to prevent them from overloading the runtime. To solve your issue, write wait()
next to do
.
Here is the full script:
01 | local sound = game.Workspace.Sound |
02 |
03 | local songs = { 2870416424 , 1837466718 , 1838103223 } |
04 |
05 | local Song = 1 |
06 |
07 | sound.Looped = false |
08 |
09 | while true do |
10 | function setSong() |
11 |
12 | local song = songs [ Song ] |
13 |
14 | print (Song) |
15 |