Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my music script stop and in output it says "Game script timeout"?

Asked by 5 years ago

At the first line it just say "Game script timeout" in output.

1if not sound.IsPlaying then
2    setSong()
3    sound:Play()
4end

I hope one of you guys can help me. - Toby

0
(There are more in it, for example the "setSong()" is a function in the script. It's just the first line it's stops at.) tobiO0310 58 — 5y
0
Can you explain clearly please nkminion 21 — 5y
0
Look down, I posted the full script. tobiO0310 58 — 5y

2 answers

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

Here is the full script:

01local sound = game.Workspace.Sound
02 
03local songs = {2870416424, 1837466718, 1838103223}
04 
05local Song = 1
06 
07sound.Looped = false
08 
09while true do
10    function setSong()
11 
12        local song = songs[Song]
13 
14        print(Song)
15 
View all 33 lines...

Answer this question