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

How do i make sound stop when a new sound plays?

I just learned how too make sound play when the player touches a brick, but when the player enters a different room how do i make the first sound stop, and another sound play when they touch a different brick?

1 answer

The Stop() method is what you would use to stop the sound.

Here's a wiki page

You would use it in the same way that you used the Play() method:

local Sound = workspace.ExampleSound

Sound:Stop()

EDIT

To have it so that it stops the sounds when you touch a button, use the Touched event on your button part:

local Part = workspace.Part
local Sound = workspace.ExampleSound

Part.Touched:connect(function(ThingThatTouched) --Will run when "Part" is touched

	if (ThingThatTouched.Parent:FindFirstChild("Humanoid")) then --If it is a player/NPC

		Sound:Stop()

	end

end)

5 comments

0

But i need to make it so that when you touch a brick, the sound stops

0

@AsrielDreams Editted

0

local sound = Instance.new("Sound", Workspace) sound.Pitch = 1 -- Speed of the song (Preffer not to change it) sound.SoundId = "rbxassetid://321702143" -- Put the last numerbs of the link of the song(ROBLOX) that you want sound.Volume = .5 -- Volume(How much power) of the song sound.Looped = true -- If you want the song to repeat after the song is don script.Parent.Touched:connect(function()

0

Didint work, if it helps that was the sound script i put into the brick

0

Remember that it isn't our job to do it all for you. We will help you along, but it's up to you to write the code.

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