I’m trying to make it so only sounds in a specific position (or basepart) can be heard, meaning background noise will be either muted or blurred out, I thought SetListener would work best since I don’t have to use any connections or loops. But it wouldn’t work as outside sound would still play.
local Character = script.Parent
local Humanoid:Humanoid? = Character:WaitForChild("Humanoid")
local IsTouching = false
local SoundService = game:GetService("SoundService")
workspace.Listener.Touched:Connect(function(Part)
IsTouching = Part:IsDescendantOf(Character)
print(IsTouching)
end)
while true do
if IsTouching then
print(true)
SoundService:SetListener(Enum.ListenerType.CFrame, workspace.Listener.CFrame)
else
SoundService:SetListener(Enum.ListenerType.Camera)
end
task.wait(1)
end