Play Sound Script not Working

I’m trying to play music within a set area but nothing happens.
I followed AlvinBlox’s tutorial (Roblox - Play music in different areas - Scripting tutorial (2020 updated version) - YouTube) which was made in 2019 so it could possibly be outdated. Nothing happens in the output other than this (when you start the game):
Infinite yield possible on ‘Workspace:WaitForChild(“SoundRegion”)’

Script:

local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegion")

local Found = false

while wait(1) do
	
	for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
		
		Found = false
		local region = Region3.new(v.Position - (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
				break
			else
				Found = false
				print("Player was not found in region")
			end
		end
		
		if Found == true then
			--Start playing some music
			if script.Parent.SoundRegions[v.Name].IsPlaying == false then
				script.Parent.Soundregions[v.Name]:Play()
				break
			end
		else
			script.Parent.SoundRegions[v.Name]:Stop()
		end
		
	end
end


and here’s the tutorial’s code:

1 Like

Have you got a folder in workspace named SoundRegion

Do you have a folder in Workspace which is named SoundRegion?

You are supposed to store the sound parts in that folder so it will loop through all of them.

I can also see that in the video it is SoundRegions and you have done SoundRegion.

Check your workspace to make sure that your folder with the regions in is called SoundRegion without the “s”

the one in the workspace is called SoundRegions

i fixed that and it still doesn’t work but has a different error

what is the error now, can you send it?

I had misspelled 2 things lmao now it works

nice one, @ me if you have any other problem, glad to help

1 Like