How to know if the player hears a sound

I want to know what command I use to know if the player hears a sound from the work area and to stop one of them SoundService

1 Like

Do you have any script for creating the sound?
If you do please show it, also I’m not an expert Witt sounds but I think checking how loud the sound is and making a theoretical circle outside of it and check it the Player is in the circle should do the trick
(Sorry for late reply, I was scrolling down your topics section and saw this)

There are no commands nor API to detect whether or not a Player hears a sound. However, you may combine the Sound.Played event (or Sound:GetPropertyChangedSignal("IsPlaying")) and Sound.RolloffMaxDistance of a Sound object.

That wouldn’t work.

while true do
	task.wait(1)
	if (player.Character:FindFirstChild("HumanoidRootPart").Position.Magnitude - workspace.R6.Head.Sound.RollOffMaxDistance) <= 7 then -- Never fires 
		print("close")
	else
		print(math.floor(player.Character:FindFirstChild("HumanoidRootPart").Position.Magnitude - workspace.R6.Head.Sound.RollOffMaxDistance)) -- Prints higher number when close, lower when far.
	end
end
1 Like

Did you mean to subtract the camera’s CFrame position to the sound’s parent’s CFrame position, get its magnitude, and compare to RolloffMaxDistance?

local Sound = workspace.R6.Head.Sound
local Camera = workspace.CurrentCamera

while true do
	local Distance = (Camera.CFrame.Position - Sound.Parent.CFrame.Position).Magnitude
	
	if Sound.IsPlaying and Distance < Sound.RolloffMaxDistance then
		print("I can hear it")
		continue
	end
	
	print("I can't hear it.")
end
4 Likes

Agree who @weakroblox35 or @Y_VRN I give the solution to?

1 Like

Usually you give the solution to the one which replied first, in this case being @Y_VRN, but if their solution is less efficient than another person, you would give it to the person that has the best script in terms of efficiency, less and practices etc.

Useless Info

Even though I was the first to say that, but he gave the correct info

1 Like

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