FIX NEEDED - Annoying swash sound that plays on repeat when enemies are killed

I’ve been making my game for a while now and it’s in its final iteration. The map is coming along nicely and the last glaring issue is this annoying noise the AI plays after death.

Here’s a clip of the bug happening

Does anyone know why this could be happening? I’ve already tried looking through both the weapon and the AI model, but neither of them include that specific sound in their model nor has anything ever appeared in the console. This noise does NOT always happen but it’s around a 70% chance. I believe it is definitely a problem with the AI itself as the same exact noise appears when you kill them with a different gun.

I am by no means a scripter at all which explains all the errors in the log, but I am trying my best solve things by myself but this I cannot figure out.

Any help I would massively appreciate

1 Like

You should check if there is any audio object being created in the ‘AI Script’

If it occurs only when they die, there’s probably a ‘Humanoid.Died’ connection. You could control F this to see if you can find it.

If there is a sound or a cloned sound in the script, simply delete it or comment it out

1 Like

It seems there is only one line of code in the entire AI module which uses ‘Humanoid.Died’ which is to change its face so I’m still unsure of what causes it. Still thank you for replying

Could you send the script inside the AI and the modules please? I think the issue is coming from one of those.

1 Like

This is the humanoid handler that I believe could have been the cause. I found a sound play file in the onDied function but it references a sound file that I can’t find anywhere else in the model. I’ve deleted it in one of the soldiers but I’ve been unable to test if it was the cause.

myHuman.Died:Connect(function()
	diedSound:Play()
	actions.yieldM4()
	actions.updateFace("Dead")
	if marine.Settings.PlayDeathAnimation.Value == true then
		myHuman.BreakJointsOnDeath = false
		marine.HumanoidRootPart.Anchored = true
		DeathAnimation:Play()
		DeathAnimation.Stopped:Wait()
	end
	for i,v in ipairs(marine:GetDescendants()) do
		if v:IsA("BallSocketConstraint") then
			v.Enabled = true
		elseif v:IsA("BasePart") and v.Name ~= "myHumanoidRootPart" then
			v.CanCollide = false
		elseif v:IsA("Motor6D") then
			v:Destroy()
		end
	end
	if marine.Settings.Respawn.Value then
		wait(marine.Settings.RespawnDelay.Value)
		clone.Parent = marine.Parent
		ArmorDurability = MaxArmorDurability
	end
	for i,v in ipairs(marine:GetDescendants()) do
		if v:IsA("BasePart") or v:IsA("Decal") then
			game:GetService("TweenService"):Create(v,TweenInfo.new(0.2),{Transparency = 1}):Play()
		end
	end
	rotAttach1:Destroy()
	wait(0.2)
	marine:Destroy()
end)

I don’t actually know if I’m meant to upload this amount of code, especially since it’s from the toolbox but this is most of the code

local soundSpeeds = {0.9,0.95,1,1.05,1.1}
myHuman.HealthChanged:Connect(function(health)
	if ArmorDurability > 0 then
		local damageTaken = oldHealth - health
		
		if (ArmorDurability - damageTaken) <= 0 then
			ArmorDurability = 0
			marine.Torso.ArmorBroken:Play()
			
			local Info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
			local Properties1 = {BackgroundTransparency = 1}
			local Properties2 = {ImageTransparency = 1}
			
			ArmorFill.Size = UDim2.new(0, 0, 1, 0)
			
			for i,v in pairs(ArmorGUI:GetDescendants()) do
				if v:IsA("Frame") then
					local Tween = TweenService:Create(v,Info,Properties1)
					
					Tween:Play()
				elseif v:IsA("ImageLabel") then
					local Tween = TweenService:Create(v,Info,Properties2)
					
					Tween:Play()
				end
			end
		else
			ArmorDurability -= damageTaken
			
			ArmorFill.Size = UDim2.new((ArmorDurability / MaxArmorDurability) * 1, 0, 1, 0)
			
			myHuman.Health = oldHealth
		end
	end
	
	if health < oldHealth and hurtSound.IsPlaying == false then
		status:set("tookDamage",true)
		if math.random(3) == 1 then
			hurtSound.PlaybackSpeed = soundSpeeds[math.random(#soundSpeeds)]
			hurtSound:Play()
		end
		core.spawn(function()
			actions.updateFace("Hurt")
			wait(1)
			if myHead:FindFirstChild("faceHurt") then
				actions.updateFace(status:get("mood"),true)
			end
		end)
	end
	
	oldHealth = myHuman.Health
	
	if myHuman.Health <= 0 then
		local Info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
		local Properties1 = {BackgroundTransparency = 1}
		local Properties2 = {ImageTransparency = 1}

		HealthFill.Size = UDim2.new(0, 0, 1, 0)

		for i,v in pairs(HealthGUI:GetDescendants()) do
			if v:IsA("Frame") then
				local Tween = TweenService:Create(v,Info,Properties1)

				Tween:Play()
			elseif v:IsA("ImageLabel") then
				local Tween = TweenService:Create(v,Info,Properties2)

				Tween:Play()
			end
		end
	else
		HealthFill.Size = UDim2.new((myHuman.Health / myHuman.MaxHealth) * 1, 0, 1, 0)
		
		if myHuman.Health < 45 then
			for i,v in pairs(HealthFrame:GetChildren()) do
				if v.Name == "Borders" then
					v.BackgroundColor3 = Color3.fromRGB(189, 63, 63)
				end
			end
			
			HealthBar.BorderColor3 = Color3.fromRGB(189, 63, 63)
			HealthFill.BackgroundColor3 = Color3.fromRGB(189, 63, 63)
			HealthShading.BackgroundColor3 = Color3.fromRGB(194, 87, 87)
			
			HealthFrame.ImageLabel.ImageColor3 = Color3.fromRGB(189, 63, 63)
		else
			for i,v in pairs(HealthFrame:GetChildren()) do
				if v.Name == "Borders" then
					v.BackgroundColor3 = Color3.fromRGB(0, 189, 0)
				end
			end

			HealthBar.BorderColor3 = Color3.fromRGB(0, 189, 0)
			HealthFill.BackgroundColor3 = Color3.fromRGB(0, 189, 0)
			HealthShading.BackgroundColor3 = Color3.fromRGB(115, 189, 102)

			HealthFrame.ImageLabel.ImageColor3 = Color3.fromRGB(0, 189, 0)
		end
	end
end)

Is the sound you’re playing inside of Humanoid.Died on repeat? Is Sound.Looped true?

1 Like

I added 2 lines of code to make it so it waits until the sounds stop playing to delete it and continue running the function but that might need to get replaced by an actual function if it doesn’t work.

Could you try that out and tell me about it.
Note: I might be not able to answer back until in a couple hours later but if that doesn’t work try changing what i’ve added to the end of the death function or using

diedSound.Ended:Connect(function()
diedSound:Destroy()
end)

myHuman.Died:Connect(function()
	diedSound:Play()
diedSound.Ended:Wait()
diedSound:Destroy()
	actions.yieldM4()
	actions.updateFace("Dead")
	if marine.Settings.PlayDeathAnimation.Value == true then
		myHuman.BreakJointsOnDeath = false
		marine.HumanoidRootPart.Anchored = true
		DeathAnimation:Play()
		DeathAnimation.Stopped:Wait()
	end
	for i,v in ipairs(marine:GetDescendants()) do
		if v:IsA("BallSocketConstraint") then
			v.Enabled = true
		elseif v:IsA("BasePart") and v.Name ~= "myHumanoidRootPart" then
			v.CanCollide = false
		elseif v:IsA("Motor6D") then
			v:Destroy()
		end
	end
	if marine.Settings.Respawn.Value then
		wait(marine.Settings.RespawnDelay.Value)
		clone.Parent = marine.Parent
		ArmorDurability = MaxArmorDurability
	end
	for i,v in ipairs(marine:GetDescendants()) do
		if v:IsA("BasePart") or v:IsA("Decal") then
			game:GetService("TweenService"):Create(v,TweenInfo.new(0.2),{Transparency = 1}):Play()
		end
	end
	rotAttach1:Destroy()
	wait(0.2)
	marine:Destroy()
end)
1 Like

The thing is I don’t know what sound it is playing since the sound it plays isn’t anywhere in the model. I also couldn’t find anything related to “Sound.Looped” either, but thank you for replying to me

I’ve tested this 10 times with 3 NPCs that use this updated code and 3 NPCs that use the original code

They were all killed with the same weapon

  1. No noise from either set
  2. Only noise from old code set
  3. Only noise from old code set
  4. Only noise from old code set
  5. Only noise from old code set
  6. Only noise from old code set
  7. No noise from either set
  8. Only noise from old code set
  9. No noise from either set
  10. Only noise from old code set

I think it’s safe to say this has worked, thank you!

If any of you want to test how they work in the actual game I have made it public for a short while in case anyone would like to test it: Sub-Zero Compound Delta [WIP] - Roblox

(All the NPCs you encounter will have been updated with this script)

And also thank you to everybody else who has given my suggestions I appreciate it

1 Like

Great to hear, i’m glad to have helped!

1 Like

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