Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not stopping the sound?

I have a DJ panel, and I want them to play a song when they click the textbutton, but I don't want them to play 2 songs at a time. So I made this script but it doesn't stop the sound from playing if another one already is?

local s = game.Workspace.Part.Sound
local s2 = game.Workspace.Part.Sound2
local b = script.Parent.Parent.Song2.Script

script.Parent.MouseButton1Down:connect(function()
s.SoundId = "rbxassetid://148321914"
s:Play()
if s2.IsPlaying == true then 
   s:Stop()
   print("yes")
end
end)


8 comments

0

any errors and is it printing yes??

0

No errors, but it does print yes. It just doesn't stop the sound.

0

This might be a roblox glitch, because it's been happening a lot recently.

0

Yes, there have been a lot of glitches, In my game I provide the boombox. And I cant turn the music off once i start it, even if i change the audio.

0

Alright, then how can I edit this to go around this glitch?

0

Wait it out

0

Set the sound's ARCHIVABLE property to false before playing it.

0

Should line 9 be "s2:Stop()"?

1 answer

There may be an error, correct me if I am wrong. I don't think "IsPlaying" is a bool.

local s = game.Workspace.Part.Sound
local.s2 = game.Workspace.Part.Sound2
local b = script.Parent.Parent.Song2.Script

script.Parent.MouseButton1Down:connect(function()
	s.SoundId = "rbxassetid://148321914"
	s:Play()
	if s2.IsPlaying then
		s:Stop()
		print("yes")
	end
end)

Leave a comment if it didn't work!

2 comments

0

Didn't stop the song..

0

@sidekick, according to the ROBLOX Wiki the IsPlaying is a boolean, please look up before answering.

This discussion is preserved as it was. New answers, comments, and votes are closed.