Gun firing sound stops playing

  1. What do you want to achieve? Keep it simple and clear!

Fix gunfire sound stopping to play.

  1. What is the issue? Include screenshots / videos if possible!

The fire sound resets for 0.1 seconds, so it starts playing again. It breaks like this:

(edit: The gun is supposed to fire every 0.1 second, asking for a way to make the sounds not break with the 0.1)


  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Nil

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Really basic local script example:

while wait() do
	local p = game.Players.LocalPlayer

	if isFire == true then
		if isDown then
			
			if db == false then
				
		db = true
				script.Parent.RemoteEvent:FireServer()
				wait(0.1)
				db  = false
				end

		end
	end
end

script example:

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	script.Parent.Handle.Fire:Play()
end)
2 Likes

Could be that the wait(0.1) statement is too short, causing the sound to start playing again, before the first sound has finished. Can you try increasing the wait to like .5? Also, you may want to check the length of the sound.

1 Like

The thing is, the gun is supposed to fire every 0.1 second.
I’m asking for a way to make the sounds work with the 0.1 (so they don’t break).

Ok I see – so you want the gun to fire every 0.1s. Do you know if the sound clip is 0.1s (or less?) At the end of the video, I can hear a “whoosh” sound for the end of the sound clip. I’m guessing the sound clip is longer than 0.1s.

You could check Fire.TimeLength to see if it’s longer than 0.1s. Alternatively, could find another clip that’s shorter than 0.1s. I couldn’t find anything about playing the clip at faster speed.?

1 Like

Yup maybe use Sound.PlaybackSpeed

1 Like

I think you need to use a sound that plays within .1 seconds or atleast the main bullet fire sound part to negate the distortion effect

1 Like

I’ll look into it, thanks. Might work, we’ll see.

Although I advise against using this solution for performance purposes, you could clone your gunshot sound every time you fire it, set PlayOnRemove to true, and destroy the clone.

Another thing, because you are playing the sound solely on the server, there will be server-client lag, thus the gunshots might sound off at times. I suggest you use a RemoteEvent to FireAllClients to play the sound locally.

1 Like

Hmm, pretty good ideas.
Also, wouldn’t firing all clients cause more lag than Server?

It varies depending on the strength of each clients computers, but in general, it is a good practice to do such things on the client instead of the server.