Need to make a raycast ignore all players in a client sided script?

I am attempting to achieve an effect so when a player is indoors an equalizer that is a member of a sound is enabled and then when the player is outdoors it is disabled. I’m using a raycast to try and achieve this, though I’m not 100% that this is the best method to tackle this effect. I will take suggestions.

But currently the issue is i’m trying to make this ignore players, this is the current code:

local soundService = game:GetService("SoundService")

local cam = workspace.CurrentCamera

game:GetService("RunService").Heartbeat:Connect(function()
	local rayResult = workspace:Raycast(cam.CFrame.Position, Vector3.new(0, 1, 0) * 100)
	if rayResult then
		soundService.Ambience.Day.IndoorEqualizer.Enabled = true
		soundService.Ambience.Night.IndoorEqualizer.Enabled = true
		soundService.Ambience.Wind.IndoorEqualizer.Enabled = true
	else
		soundService.Ambience.Day.IndoorEqualizer.Enabled = false
		soundService.Ambience.Night.IndoorEqualizer.Enabled = false
		soundService.Ambience.Wind.IndoorEqualizer.Enabled = false
	end
end)

I’ve looked around for solutions and have found many things but they don’t seem to work maybe they are more suited for server sided scripts. Not sure this is open to any suggestions that are helpful, thanks!

What if you try make two versions of the sound like one version of the audio without the Equalizer and another one with the Equalizer. I know it’s not the best method but it’s worth a shot.

you should try using touch detection instead of raycasting to detect whether a player is inside or outside. i would recommend zone+

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.