Weapons Sound Bug

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to solve the “sound” problem because i hear the “shot” 20/30 times

  2. What is the issue? When i use my weapon the sound is played only sometimes : Roblox Weapons Sound - YouTube

  3. What solutions have you tried so far? I have tried to use the code on “local” and “server” but both doesn’t solve anything. I have tried to check if the sound is already playing but doesn’t do anything too. I have tried to check if the sound is already playing stop it and play again and doesn’t work too.

so i want to know how can i solve that because it’s very annoying and this seems to be the same on a simple tool with a script that play a sound so why ? and how can i solve that ?

Could you show us some code?

Please embed them using the ``` marks at the start and end of your code.

Example:

print("Hello World!")

so yeah but the code is too big so you can see where the sound is played.

while wait(0) do
			if Fire_Button_Pressed then
				if Can_Fire_Again then
					if Current_Bullet.Value > 0 and (not Reloading) then
						Can_Fire_Again = false
						
						Muzzle_Path.Fire:Play()

						local raycast_result = Ray_Module:CreateRayWith2Position(Muzzle_Path.Position, mouse.Hit.Position, true, Enum.RaycastFilterType.Blacklist, {tool, workspace.Ray_Folder, player_char}, nil, false, nil, nil)

						local is_player = IsPlayer(raycast_result.HitPart.Parent.Name)
						local is_zombie = (raycast_result.HitPart.Parent.Name == "Zombie")

						if raycast_result.HitPart ~= nil then	
							if is_zombie and (not Reloading) then
								mouse.Icon = "rbxassetid://6972334166"	
							end

							fire_anim = humanoid.Animator:LoadAnimation(Anims_Path.Fire_Anim)
							fire_anim:Play()

							RE_Fire:FireServer(raycast_result.HitPart.Parent, is_player, is_zombie, Muzzle_Path.Position, raycast_result.HitPos)

							fire_anim.Stopped:Wait()

							if is_zombie and (not Reloading) then
								mouse.Icon = "rbxassetid://6972322242"
							end

							wait(Shots_Speed)
						end

						Can_Fire_Again = true

					elseif Current_Bullet.Value == 0 and Current_Mag.Value > 0 then
						if (not Reloading) then
							Reload()
						end
					end
				end
			end

			if While_Stop_Request then
				break
			end
		end

Oof, why is there a while loop in there?

Don’t you have a Tool.Activated event?

Example:

local Tool = Instance.new("Tool")

Tool.Activated:Connect(function()
	print("Tool activated!")
end)
1 Like

sorry for the late answer but yes i have an “activated and deactivated” event but this control the “Fire_Button_Pressed” variable but the “sound problem” is on my pistol script too

Instead of making the “Fire_Button_Pressed” change on Tool.Activated and then checking if Fire_Button_Pressed is true in a separate script, connect the Tool.Activated directly to the script you sent earlier. You may have a reason for why you are doing it in this way but you may want to reconsider how you are triggering your shooting script.

i have already tried in a new game with a new tool and only a script with “tool.Activated:Connect” and i get the same problem but this seems to be the “Playbackspeed” because when he is on “1” it work but after it doesn’t work so it’s strange

Could you provide the exact code you are using in the new game?

script.Parent.Activated:Connect(function()
      script.Parent.Handle.Fire:Play()
end)

Yeah but, your fire script? The one where you do the shooting itself. Do you still use some while loop somewhere?

no because i have tried with only the script above and it doesn’t work.