Problems with sound regions script

I’m making a waterfall area in which when you get near the part that resembles the watersfall(below)

You hear a sound of rushing water.
So I watched a video by AlvinBlox: Roblox - Play music in different areas - Scripting tutorial (2020 updated version) - YouTube

And I made a folder called SoundRegions

Then made a folder in StarterGUI named SoundRegions.
In the folder I put my sound:

And I put a localscript that did everything.


local SoundRegionsWorkspace = game.Workspace:WaitForChild(“SoundRegions”)

local Found = false

while wait(1) do

for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
	Found = false
	local region = - (v.Size/2),v.Position + (v.Size/2))
	local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
	for _, part in pairs(parts) do
		--Loop one by one through the parts table.
		if part: FindFirstAncestor(game.Players.LocalPlayer.Name) then 
			print("Player was found")
			Found = true
			Found = false
			print("Player was not found in region")
		if Found == true then
			--Play da music!
			if script.Parent.SoundRegions[v.Name].IsPlaying == false then

Idk why Devforum cut off a part of it

I’m pretty new to scripting so I tried to follow along with the video the best I could. I’m pretty sure what it does is that it constantly checks if the player is in a region, then if they are in the region, it checks if the audio is playing, and if it’s not playing, then it plays the audio until the player moves out of the region.

So the script didn’t work. I checked the names and made sure they were the same.

What I’m pretty sure is causing the script to not work is that I also have a script in which when you step into the water part, it plays an underwater sound. For that, I have a folder named “Water” in which there are parts which if you step into it, they play the underwater noise.

So here is a picture of the sound region with the waterfall part, which is named “waterfallwater”

Red= sound region
Blue=water part

Why loop though it like that? You can just use CollectionService to get the specified parts you want.

1 Like

Why not just put a Sound in the Part there that plays all the time? No scripting involved! In the script you have the Sound only plays for the Player inside the Region. A Sound in a Part works better.

I have the Diesel Engine Sound playing in this Wedge, when a player gets close they hear it because it’s Playing, and Looped all the time. The RollOff distances are when is starts to get quieter (Min) and where they can’t hear it at all (Max):

1 Like

When the sound plays, it’s local right? So only the players who step in can hear it?

That’s what the Sound RollOff is for, you can change them to make it more realistic.
If you make the RollOffMaxDistance 10 studs then when a Player gets within 10 studs of the Part they’ll start to hear it.
The RollOffMinDistance is where the volume of the Sound starts to fade when you get farther from the Part. A MinDistance of 1 stud means the Player will hear the sound at max volume when they’re 1 stud from the Part and when then start to walk away it’ll gradually get quieter until they reach the MaxDistance.

1 Like

I get it, but when a player steps in, it doesn’t play the sound for everyone right?

1 Like

That’s why it’s a local sound, it only plays at that distance around that Part. If you aren’t close, you don’t hear it.