Walk sound effects sound really off

I got this code that raycasts down, gets the material of a block, and applies a SFX to the Running Sound in the character, for custom running sounds. However, 2 issues are the delay between sound changes and the “default” sound (the sound over the grey/black blocks) is incredibly fast, thus making it sound like you are doing more steps then you actually are.


Normally, I’d mute the Running sound and edit the run animation to include an event when steps, but I can’t do this as this game allows users to change their animations.

WalkParams.FilterDescendantsInstances = { self.Character }

while self.Character == character do
	task.wait()

	-- Handle footstep sound effects
	local Raydown = workspace:Raycast(self.Character.HumanoidRootPart.Position, Vector3.new(0, -5, 0), WalkParams)
	if not Raydown or not Raydown.Instance then
		continue
	end

	local FootstepSound = FootstepSounds[Raydown.Material.Name]
	if not FootstepSound then -- Couldn't find, use default
		FootstepSound = FootstepSounds.Default
	end

	if self.Character.HumanoidRootPart.Running.SoundId == FootstepSound.Id then
		continue -- Already this Id
	end

	self.Character.HumanoidRootPart.Running.SoundId = FootstepSound.Id
	self.Character.HumanoidRootPart.Running.Volume = FootstepSound.Volume
end