I would like to know if there’s a way to prevent this popping sound from happening, but I would also like to know if there are any better ways to implement footstep sounds.
Sounds like maybe the sound is playing with every step taken, so maybe implement a short cooldown or change the sound to Playing while the player is walking, and turn it off when the Player stops movement.
I used ChatGPT, but this assumes “Footsteps” audio is in SoundService, and seems to detect it through the Player’s speed.
local SoundService = game:GetService(“SoundService”)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local footsteps = SoundService:WaitForChild(“Footsteps”) – Reference to the Footsteps sound
– Play footsteps when the player is walking, stop when they stop
humanoid.Running:Connect(function(speed)
if speed > 0 then
if not footsteps.IsPlaying then
footsteps:Play()
end
else
footsteps:Stop()
end
end)
This half works. The audio artifact has disappeared but now my issue is that the footstep sound isn’t playing when the foot is placed on the ground. I would assume KeyframeMarker might fix the issue but I would have to shoehorn that into the NPC’s Animate script which likely won’t work.
Listening for an animation event in the animate script worked but it created the audio artifact. I’m assuming that the audio artifact/popping sound is an engine issue. If it isn’t, it probably comes from the sound overlapping itself. But the solution was to put this inside the animate script in the playAnimation function:
-- play the animation
if animName == "Walk" or "Run" then
currentAnimTrack:Play(transitionTime, 1, 0.7) --used to play walk animation at specific speed
currentAnimTrack.Priority = Enum.AnimationPriority.Action3
currentAnimTrack:GetMarkerReachedSignal("Footstep"):Connect(function() --animation event listener
workspace.Breadian.HumanoidRootPart.footstep01:Play()
end)
else
currentAnimTrack:Play(transitionTime)
end