Script doesn't recognize other Footsteps Sounds

One of my games has a footstep script that uses Animation Events and has multiple sounds to each material there currently is. But, for some reason, it only plays the default footsteps (which is Plastic) and not the other ones (ex. Concrete, Pebble, Snow, Metal, etc)

Here’s the entire script that handles the footsteps

local player = game.Players.LocalPlayer
local Char = player.Character or player.CharacterAdded:Wait()
local HRP = script.Parent:WaitForChild("HumanoidRootPart")

local Hum = script.Parent:WaitForChild("Humanoid")
local sound = HRP:WaitForChild("Running") sound.Volume = 0

local plr = script.Parent

local FootstepEndEvent = game.ReplicatedStorage:WaitForChild("FootstepEnded")

local CanRelease = true
local CanStep = true
local CanBetween = true
local CanHandStep = true
local CanWallStep = true
local CanHandStepRelease = true

local RS = game:GetService("RunService")
local MaxSpeed = 90
local CurrentVolume = 0
local TargetVolume = 0

local head = script.Parent:WaitForChild("Head")
local Wind = script:WaitForChild("Wind")
local ClothAmbient = Wind:WaitForChild("Cloth")
local WindAmbient = Wind:WaitForChild("Wind")
local RaycastParam = RaycastParams.new()
RaycastParam.FilterDescendantsInstances = Char:GetDescendants()

local SoundScript = require(player.PlayerScripts.Modules:WaitForChild("Sounds"))

local SoftMaterials = {Enum.Material.Air, Enum.Material.ForceField, Enum.Material.Neon, Enum.Material.Foil, Enum.Material.Sand, Enum.Material.Glass, Enum.Material.Fabric, Enum.Material.Grass}

game.Players.LocalPlayer.Character.Humanoid.AnimationPlayed:Connect(function(track)
	--if track.Name == "RunAnim" or track.Name == "WalkAnim" then
	local R
	local Folder = HRP.Concrete
	local IsSoft = false
	track:GetMarkerReachedSignal("Footstep"):Connect(function()
		if CanStep == true then
			if track.Name == "WallClimb" then
				R = workspace:Raycast(HRP.Position, HRP.CFrame.LookVector * 3, RaycastParam)
			else
				R = workspace:Raycast(HRP.Position, Vector3.new(0,-3.5,0), RaycastParam)
			end
			if R and R.Instance.Name == "Water" then
				Folder = HRP:FindFirstChild("Water")
			elseif R then
				Folder = HRP:FindFirstChild(string.split(tostring(R.Instance.Material), ".")[3])
				if table.find(SoftMaterials, R.Instance.Material) then
					IsSoft = true
				end
				if not Folder then
					Folder = HRP.Concrete
				end
			end
			CanStep = false
			spawn(function()
				CanStep = true
			end)
			for i,v in pairs(Folder.Step:GetChildren()) do
				for i,v2 in pairs(HRP:GetChildren()) do
					if v2.Name == v.Name then v2:Destroy() end
				end
			end
			local s = Folder.Step:GetChildren()[math.random(1, #Folder.Step:GetChildren())]:Clone()
			--s.Name = "Step"
			s.Parent = HRP
			s:Play()
			SoundScript.PlaySound(s.Name)
			s.Ended:Connect(function()
				s:Destroy()
			end)
		end
	end)
end)

--[[RS.Heartbeat:Connect(function()
	CurrentVolume = CurrentVolume + (TargetVolume - CurrentVolume) * 0.1
	--print(CurrentVolume)
	local Velocity = HRP.AssemblyLinearVelocity.Magnitude
	TargetVolume = (Velocity / MaxSpeed) + 0
	ClothAmbient.Volume = CurrentVolume
	WindAmbient.Volume = CurrentVolume
	if ClothAmbient.Volume >= 2 then	ClothAmbient.Volume = 2 end
	if WindAmbient.Volume >= 2 then WindAmbient.Volume = 2 end
end)]]

Here’s a video showing the problem:

If anyone could help i would appreciate it, thanks.

1 Like

Hi @ShyowwTheDev,

Would it be possible if you could provide a stripped-down version of the studio so I can find a solution for your issue? I lack information related to your code to assume a possible solution to your code (please add comments :frowning: ). The good news is that your detection logic (which I’ve simplified) is functional, and it seems to be related to your setup.

If you’re talking all the scripts i used for the footstep system then.

Here’s the code inside them:

Sounds:

local module = {}
local Player = game.Players.LocalPlayer
local RE = game.ReplicatedStorage.Sounds

function module.PlaySound(Sound, Is2D)
	if type(Sound) ~= "string" then
		if Is2D == true then
			local NewSound = Sound:Clone()
			NewSound.Parent = game.SoundService
			NewSound:Play()
			NewSound.Ended:Wait()
			NewSound:Destroy()
		else
			Sound:Play()
		end
	end
	RE:FireServer(Sound)
end

RE.OnClientEvent:Connect(function(Plr, Sound)
	if Player ~= Plr then
		Sound:Play()
	end
end)

return module

Ambient Audio:

DM:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local plr = Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local torso = char:FindFirstChild("Torso")

local RootJoint = hrp:FindFirstChild("RootJoint")
local Neck = torso:WaitForChild("Neck")
local RightShoulder = torso:WaitForChild("Right Shoulder")
local LeftShoulder = torso:WaitForChild("Left Shoulder")
local RightHip = torso:WaitForChild("Right Hip")
local LeftHip = torso:WaitForChild("Left Hip")

----motor6dss

local RootJointC0 = RootJoint.C0
local NeckC0 = Neck.C0
local RightShoulderC0 = RightShoulder.C0
local LeftShoulderC0 = LeftShoulder.C0
local RightHipC0 = RightHip.C0
local LeftHipC0 = LeftHip.C0


----

local RJTilt = CFrame.new()
local NTilt = CFrame.new()
local RSTilt = CFrame.new()
local LSTilt = CFrame.new()
local RHTilt = CFrame.new()
local LHTilt = CFrame.new()

local deflerp = 0.2
local dotthresholddddd = 0.8 
local lastTime = 0
local tickRate = 1 / 60 

function updatecharacater(DTime)
	local Now = workspace:GetServerTimeNow() 

	if Now - lastTime >= tickRate and shared.dashingval == false then
		
		lastTime = Now

		local MoveDirection = hrp.CFrame:VectorToObjectSpace(hum.MoveDirection)

		if MoveDirection:Dot(Vector3.new(1,0,-1).Unit) > dotthresholddddd then
			-- print("Forwards-Right")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 5, 0, math.rad(-MoveDirection.X) * 25), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 5, 0, math.rad(MoveDirection.X) * 15), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(1,0,1).Unit) > dotthresholddddd then
			-- print("Backwards-Right")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 5, 0, math.rad(MoveDirection.X) * 25), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 5, 0, math.rad(-MoveDirection.X) * 25), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(-1,0,1).Unit) > dotthresholddddd then
			-- print("Backwards-Left")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 5, 0, math.rad(MoveDirection.X) * 25), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 5, 0, math.rad(-MoveDirection.X) * 25), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(MoveDirection.X) * 10, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(-1,0,-1).Unit) > dotthresholddddd then
			-- print("Forwards-Left")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 5, 0, math.rad(-MoveDirection.X) * 25), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 5, 0, math.rad(MoveDirection.X) * 15), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 10, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(0,0,-1).Unit) > dotthresholddddd then
			-- print("Forwards")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 10, 0, 0), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 10, 0, 0), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(1,0,0).Unit) > dotthresholddddd then
			-- print("Right")

			RJTilt = RJTilt:Lerp(CFrame.Angles(0, 0, math.rad(-MoveDirection.X) * 35), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(0, 0, math.rad(MoveDirection.X) * 35), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(0,0,1).Unit) > dotthresholddddd then
			-- print("Backwards")

			RJTilt = RJTilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * 10, 0, 0), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * 10, 0, 0), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection:Dot(Vector3.new(-1,0,0).Unit) > dotthresholddddd then
			-- print("Left")

			RJTilt = RJTilt:Lerp(CFrame.Angles(0, 0, math.rad(-MoveDirection.X) * 35), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(0, 0, math.rad(MoveDirection.X) * 35), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, math.rad(-MoveDirection.X) * 15, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		elseif MoveDirection == Vector3.new(0, 0, 0) or script:GetAttribute("Toggle") == false then
			RJTilt = RJTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RootJoint.C0 = RootJointC0 * RJTilt

			NTilt = NTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			Neck.C0 = NeckC0 * NTilt

			RSTilt = RSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightShoulder.C0 = RightShoulderC0 * RSTilt

			LSTilt = LSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftShoulder.C0 = LeftShoulderC0 * LSTilt

			RHTilt = RHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			RightHip.C0 = RightHipC0 * RHTilt

			LHTilt = LHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
			LeftHip.C0 = LeftHipC0 * LHTilt
		end
	elseif shared.dashingval == true then
		RJTilt = RJTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		RootJoint.C0 = RootJointC0 * RJTilt

		NTilt = NTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		Neck.C0 = NeckC0 * NTilt

		RSTilt = RSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		RightShoulder.C0 = RightShoulderC0 * RSTilt

		LSTilt = LSTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		LeftShoulder.C0 = LeftShoulderC0 * LSTilt

		RHTilt = RHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		RightHip.C0 = RightHipC0 * RHTilt

		LHTilt = LHTilt:Lerp(CFrame.Angles(0, 0, 0), deflerp)
		LeftHip.C0 = LeftHipC0 * LHTilt
	end
end

RunService.Heartbeat:Connect(updatecharacater)

Sounds inside of Modules:

local module = {}
local Player = game.Players.LocalPlayer
local RE = game.ReplicatedStorage.Sounds

function module.PlaySound(Sound, Is2D)
	if type(Sound) ~= "string" then
		if Is2D == true then
			local NewSound = Sound:Clone()
			NewSound.Parent = game.SoundService
			NewSound:Play()
			NewSound.Ended:Wait()
			NewSound:Destroy()
		else
			Sound:Play()
		end
	end
	RE:FireServer(Sound)
end

RE.OnClientEvent:Connect(function(Plr, Sound)
	if Player ~= Plr then
		Sound:Play()
	end
end)

return module

Yea it’s way too much code i’m sorry.

Turns out the problem was my avatar and not the actual game’s script, sorry for wasting your time.

1 Like

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