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

When I mute the music, I can't make it play back, what happened?

Asked by 6 years ago
01local function songs ()
02    while true do
03        game.Workspace.Songs.DarudeSand:Play()
04        wait(123)
05        game.Workspace.Songs.Bangarang:Play()
06        wait(94)
07        game.Workspace.Songs.ET:Play()
08        wait(119)
09        game.Workspace.Songs.Poison:Play()
10    end
11 
12    songs()
13 
14 
15    script.Parent.Parent.StarterGui.ShopAct.Frame.ImageButton.MouseButton1Click:Connect(function()
View all 24 lines...

Whenever I try to unmute the music, the output says that Songs doesn't belong to workspace anymore but that's why I added the elseif

1
If something may not exist, use Instance:FindFirstChild() Optikk 499 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Here, I have a way better solution -- you don't have to delete anything!

01local play = true
02local debounce = false
03local Songs = game.Workspace.Songs
04 
05local function songs ()
06    while true do
07        Songs.DarudeSand:Play()
08        wait(123)
09        Songs.Bangarang:Play()
10        wait(94)
11        Songs.ET:Play()
12        wait(119)
13        Songs.Poison:Play()
14end
15 
View all 39 lines...

I simply defined a boolean value that can be set to true or false judging by the button press, a debounce is added so it isn't constantly changing the value.

Once the "if" statements decide whether to be false or true, it then does a loop of the Songs folder/model and checks if a certain member of the model (v) is a sound. Once it figures that out, it pauses or resumes it judging by whether play is false or true.


Although, if you want, I do have a huge module script that you could use to play your songs alternatively instead of ":Play()"

https://forum.scriptinghelpers.org/topic/725/cvextra-super-module-script

MODULE SCRIPT: https://www.roblox.com/library/2674126390/CVExtra-Super-Module-Script

A remade form using my script (THIS ASSUMES YOU PUT THE MODULE SCRIPT IN THE WORKSPACE):

01local play = true
02local debounce = false
03local Songs = game.Workspace:FindFirstChild("Songs")
04local CVExtra = game.Workspace:FindFirstChild("CVExtra")
05local playAudio = CVExtra.playAudio
06 
07local function songs ()
08    while true do
09        playAudio(Songs.DarudeSand)
10    wait(0.5)
11        playAudio(Songs.Bangarang)
12        wait(0.5)
13        playAudio(Songs.ET)
14        wait(0.5)
15        playAudio(Songs.Poison)
View all 41 lines...

Do not worry about doing a whole wait of the song's length, my module script has that all done for you, and it'll wait if the audio gets paused.

Ad

Answer this question