Sound playing despite player being too far away to hear it

The problem:
Despite the sound being a sufficient distance away I am still able to hear the sound, though it seems to only be the start of the sound, It makes a “cracking” sound as if it realises after beginning to play that I shouldn’t be able to hear it.

What I’ve tried:
Other than delaying playing the sound I don’t really know what else to try, I googled it but couldn’t find anything on it and wasn’t even sure what to search.

To clarify, the sound is in the projectile, not the script and this is all local.

Here is the code that plays the sound after detecting a collision though I assume this isn’t the problem:

------------------------------------------------------------------------------------------------------------
---[Locals]-------------------------------------------------------------------------------------------------
local Debounce = false
local Snowball = script.Tracker.Value
------------------------------------------------------------------------------------------------------------
---[Prepare Sounds]-----------------------------------------------------------------------------------------
Snowball.Hit_Land.PlaybackSpeed = math.random(800,1000)/1000
Snowball.Hit_Person.PlaybackSpeed = math.random(800,1000)/1000
------------------------------------------------------------------------------------------------------------
---[Variables]----------------------------------------------------------------------------------------------
local Damage = script.Damage.Value
------------------------------------------------------------------------------------------------------------
---[Hit Detection]------------------------------------------------------------------------------------------
Snowball.Touched:Connect(function(Hit_Part)
	if Hit_Part.Parent:FindFirstChild("Humanoid") and Debounce == false and Hit_Part.Parent.Name ~= script.Blacklist.Value then Debounce = true
		-- Play snow hit effect
		Snowball.Transparency = 1
		local HitEffect = Snowball.Hit_Effect
		HitEffect.Parent = Hit_Part
		HitEffect:Emit(100)
		
		-- Play sound
		Snowball.Hit_Person:Play()
		
		-- Send result to server to replicate
		local NPC = Hit_Part.Parent
		game.ReplicatedStorage.Weapon_Events.Damage_Made:FireServer(Damage,NPC)
		
		-- Wait for sound to finish before cleanup
		Snowball.Hit_Person.Ended:wait()
		Snowball:Destroy()
		script:Destroy()

	elseif Debounce == false and Hit_Part.Parent.Name ~= script.Blacklist.Value and Hit_Part.Name ~= "Glass" then Debounce = true
		-- Play snow hit effect
		Snowball.Transparency = 1
		Snowball.Hit_Effect:Emit(100)
		
		-- Play sound
		Snowball.Hit_Land:Play()
		
		-- Wait for sound to finish before cleanup
		Snowball.Hit_Land.Ended:wait()
		Snowball:Destroy()
		script:Destroy()
		
	elseif Debounce == false and Hit_Part.Parent.Name ~= script.Blacklist.Value and Hit_Part.Name == "Glass" then Debounce = true
		-- Play snow hit effect
		Snowball.Transparency = 1
		Snowball.Hit_Effect:Emit(100)

		-- Send result to server to replicate
		local Glass = Hit_Part
		game.ReplicatedStorage.Weapon_Events.Glass_Hit:FireServer(Damage,Glass)

		-- Play sound
		Snowball.Hit_Land:Play()

		-- Wait for sound to finish before cleanup
		Snowball.Hit_Land.Ended:wait()
		Snowball:Destroy()
		script:Destroy()
	end
end)

Here is the sound Properties:

Here is an example of it happening:

It doesn’t seem to do it with a static object playing the extact same sound instance:

this may be because the sound may not be played in the workspace

The Projectile (which contains the sound) is in the Character, I also tested it being just in the workspace but that made no difference.

decrease the max distance? and why does the sound is in the character? maybe put it inside the snowball itself…

If the TimeLength is 0.952, why are you destroying the script after only 0.7 seconds? Try raising your wait() to 1. This may not be the issue, though, but worth a shot.

Is the parent a Part or a Model? Sounds don’t play at specific positions unless they’re parented to a Part or Attachment.

Is the Snowball Value a Part?

Maybe you didn’t assign the value to be the part

I’ve updated the code, no that didn’t fix it either, you can see I reorganised all the code and it now waits until the sound ends but still does the noise at the start.

Yes that’s a ObjectValue, Due to it all being local the script sits inside the main gun script while running.

No it is assigned right, It all works fine just the sound making a snap noise when it starts despite it being far away enough you shouldnt hear anything.

No, the sound is in the Snowball, the snowball was stored inside the character at the time, I’ve updated the script and you can see the Snowball is now in a folder in the workspace, still having the same issue.

Have you made sure the Sound is parented to a Part or MeshPart, and not anything else? Doing so otherwise makes the sound global.

Yes as I said in the post its located inside the Snowball which is in the workspace, I found that fact out the hard way a long time ago lol.

After more testing I’ve found that beyond a magnitude of 30 from the player, the sound has the snapping noise and doesn’t play properly, maybe it’s due to the sounds short duration?

-- Check distance and play sound
		local HRP = game.Players.LocalPlayer.Character.HumanoidRootPart
		
		if (Snowball.Position - HRP.Position).Magnitude < 30 then
			Snowball.Hit_Land:Play()
			Snowball.Hit_Land.Ended:wait()
		else
			wait(0.7)
		end

		-- Cleanup
		Snowball:Destroy()
		script:Destroy()

This is not the solution just more bug testing, I would still like a fix.

I woke up today and started to work on the game and it is no longer doing it all the time, it’s an intermittent engine bug.

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