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

Can someone tell me what is wrong in the scrip?

This script should stop a sound that is playing whit the function "PlayLocalSound"



script.Parent.Touched:connect(function()
if game.SoundService.Sound1.playing.Value == 1 then
	local stop = game.SoundService.Sound1:Stop()
	
else
end)

1 answer

Hi el_devil, I'm not sure what you're trying to do with this script but my best guess is that you're trying to make a script that stops playing a song when you touch it, then if you touch it again then it will turn back on? If I'm correct then try this:

sound = game.Soundscape.Sound1

db = true

script.Parent.Touched:connect(function()
	if db == true then
		db = false
		
		if sound.Playing == true then -- If it's playing then
			
			sound:Stop() -- stop the sound
		
		elseif sound.Playing == false then -- If it's not playing then
		
			sound:Play() -- play the sound
		
		end
		
		wait(1) -- amount of time until you can run the script again

		db = true
	end
end)

Again I'm not sure if that's what you're trying to do but it's my best guess.

1 comment

0

You don't need == true, only sound.Playing, as an if statement counts a false bool as 'non-existing' kind of.

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