Gun Sound Trouble

Hey Roblox devs. It’s much easier to just show you my problem than to explain it:
https://youtu.be/_GhE355PtDg

Let me know if the video does not work. Make sure to turn on your sound.

Is there any way I can fix this problem? If you couldn’t tell, it sounds very cheap and crappy.

Could you please provide the main script that controls the gun sound and stuff?

game.Players.PlayerAdded:Connect(function(player)
	local MuzzleEvent = player:WaitForChild("gunEvents").Muzzle
	local MuzzleStopEvent = player:WaitForChild("gunEvents").MuzzleStop
	
	MuzzleEvent.OnServerEvent:Connect(function(Player)
		local Muzzle = Player.Character.Blackout.Preview.MuzzleEffect
		local GunFire = player.Character.Blackout.GunFire
		
		GunFire.Playing = true
		Muzzle.Enabled = true
		while GunFire.Playing == true do
			print(GunFire.TimePosition)
			if GunFire.TimePosition > 5 and GunFire.TimePosition < 6 then
				GunFire.TimePosition = 0
			end
			wait()
		end
	end)
	MuzzleStopEvent.OnServerEvent:Connect(function(Player)
		local Muzzle = player.Character.Blackout.Preview.MuzzleEffect
		local GunFire = player.Character.Blackout.GunFire
		
		GunFire.Playing = false
		Muzzle.Enabled = false
	end)
end)

most of this is controlling the muzzle of the gun, and the other parts are controlling the sound. This is all under a server script.

I’m guessing this is the sound object that is the firing sound?

yep

lkaugsdflkhgasdlfgshdgflksajdhgflhasgdflkjhasdf

Ok then maybe add this after that variable is created:

local echo = Instance.new("EchoSoundEffect", GunFire)

This should hopefully make the fire sound less choppy and if it gets to loud or starts repeating, you can let me know and I’ll change the settings

doesn’t make much of a difference. This is where I downloaded the sound effect: https://www.fesliyanstudios.com/royalty-free-sound-effects-download/gun-shooting-300
scroll down to where it says “rifle automatic A sound effect”

GunFire.Playing = true

Why can’t you just use

GunFire:Play()

Also, you are resetting the TimePosition if it is greater than 5 or less than 6, which may cut it off short.

if GunFire.TimePosition > 5 and GunFire.TimePosition < 6 then
	GunFire.TimePosition = 0
end

What happens if you remove that?

(Also, on a side note, you should use task.wait() rather than wait(), it favors performance and is more accurate.)

so then what code would I do for it to stop playing

That wouldn’t change anything, and @Gvvgghnu_Lol you may want to cut off some of the rapid-fire so It’s just two or three beats. In this case, It will loop through those beats one after another because the sound is pretty long and will just continue from where it left off

GunFire:Play()

task.spawn(function()
GunFire.Ended:Wait()
GunFire:Stop()
end)

Granted, this may only work if the sound is not looped, but I don’t see a reason for it to be looped.

I reset it because it kind of echoes at the end. Look at the audio link and you’ll understand.

Are you saying my audio should be like one gun fire instead of automatic?

Audio uploads are free, you could cut it off in a program such as Audacity and then reupload it as the length you would like. Otherwise, this is a very hacky way to do it that I wouldn’t recommend.

Two or three would be recommended but if you have it on loop then it will still be automatic

I just looked at audacity. I searched “gunshot” and nothing came up

and how could I make it actually echo? If I stop the audio, then the audio is stopped, it will not echo.

I don’t know if you understand. Audacity is a program. You could download the gunshot audio file and use Audacity to trim off the parts you don’t want. It isn’t a music/sfx browser, or whatever you think it is. After you trim it, you reupload the audio and change the ID of your sound.

oh ok, sorry

alskdhjgfalksdhgflkasdgflkasdgflkjas

If you parent the echo object to the GunFire it should make it echo