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

Sounds in StarterGUI or StarterPlayer do not stop no matter what I do?

Asked by 5 years ago

For an intro for a game (that will probably not be released), I tried to implement music and sounds. Unfortunately, it seems as though the script will not stop either the song being played (script.song) or the static in the background (script.Static).

wait(11)

script.Static.Volume = 0
script.song.Volume = 0

script.song:Play()
script.Static:Play()

script.Static:Stop()
script.song:Stop()

script.Static.Playing = false
script.song.Playing = false

script.Static:Destroy()
script.song:Destroy()

As you can see here, I tried various things. The wait is there in order to line the whole thing up with the visuals, just to clarify. First, I tried doing the simple thing: stop the sound using the Stop function. But that did not stop either of the sounds. Then, I tried to use Destroy to destroy both of the sound objects. This also didn't work. Afterward, I tried to do it a bit rougher by disabling the Playing values themselves. Again, it did not work. I tried the volume, did not work. And I tried playing the song again when it's volume was down, also did not work. Also, I tried making the sound fade as well, just like the GUI, although that did not work either. Lastly, the sound script was once placed in the ScreenGUI itself. In fact, the text inside of it was once inside the LocalScript in the GUI until the problem arose.

Let me explain with this video: https://www.youtube.com/watch?v=qE5hZUBNUpA&feature=youtu.be

The sound is supposed to end right after the visuals fade. But as you can see, that did not happen, and the two sounds continued until the end.

Both sounds are set to play at the start (using Playing), and the ScreenGUI and sound scripts are both separate (in separate places) and local.

Script in the GUI:

script.Parent.Parent.Enabled = true
wait(10)
while script.Parent.ImageTransparency < 1 do
    wait(0.01)
    script.Parent.ImageTransparency = script.Parent.ImageTransparency + 0.01
    script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency + 0.01
    script.Parent.Parent.TextLabel.TextTransparency = script.Parent.Parent.TextLabel.TextTransparency + 0.01
end
script.Parent.Parent.Enabled = false

Any help would be greatly appreciated. Thanks, and happy Independence Day! - THAIRIN

0
can't you just change their position to ReplicatedStorage or something else? Is_Hunter 152 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

The Playing value cannot be modified. If you are sure you have the sound, you need to run :Stop() on it after the fading out is completed. Once your while loop is over, the remaining part of the script will proceed. After your while loop, that's where you need to stop the sound. Ensure you have the correct sound too.

Ad
Log in to vote
0
Answered by 5 years ago

Just use this, it's waaaay easier.

function onClicked()
     -- code
     script.Parent.Sound:Play()
     -- code
     script.Parent.Sound:Stop() -- if needed or use :Pause()
     -- code
end

script.Parent.MouseButton1Click:connect(onClicked)

Also, the playing value can only be looked at, not changed. such as if it's true or not.

Answer this question