How make behind the wall sound

How to Make Water Muffle In Roblox Studio! - YouTube i want to create like that but with part.

Here the script:

local Work = game:GetService(“Workspace”)
local Camera = Work.CurrentCamera
local Terrain = Work.Terrain

function CFrameToVector3(cframe)
return Vector3.new(cframe.X,cframe.Y,cframe.Z)
end

while wait() do
local REGION = Terrain:ReadVoxels(Region3.new(CFrameToVector3(Camera.CFrame)-Vector3.new(.0001,.0001,.0001), CFrameToVector3(Camera.CFrame)):ExpandToGrid(4),4)
for Number,Information in pairs (REGION[1][1]) do
for i,v in pairs(Work:GetDescendants())do
if Information == Enum.Material.Water and v:IsA(“EqualizerSoundEffect”)and v.Name ==“Muffle” then
v.Enabled = true
elseif v:IsA(“EqualizerSoundEffect”)and v.Name == “Muffle” then
v.Enabled = false
end
end
end
end

What i can rewrite here?

Add a codeblock to your script so it can be much easier to read.

(this)

I’ve taken the liberty to do it for you and them.

local Work = game:GetService(“Workspace”)
local Camera = Work.CurrentCamera
local Terrain = Work.Terrain

function CFrameToVector3(cframe)
	return Vector3.new(cframe.X,cframe.Y,cframe.Z)
end

while wait() do
	local REGION = Terrain:ReadVoxels(Region3.new(CFrameToVector3(Camera.CFrame)-Vector3.new(.0001,.0001,.0001), CFrameToVector3(Camera.CFrame)):ExpandToGrid(4),4)
	for Number,Information in pairs (REGION[1][1]) do
		for i,v in pairs(Work:GetDescendants())do
			if Information == Enum.Material.Water and v:IsA(“EqualizerSoundEffect”)and v.Name ==“Muffle” then
				v.Enabled = true
			elseif v:IsA(“EqualizerSoundEffect”)and v.Name == “Muffle” then
				v.Enabled = false
			end
		end
	end
end
1 Like

Well, considering they’re using water for this why not just change the “water” components into your path?