local H=script.Parent:WaitForChild("\070\111\111\116\115\116\101\112\083\111\117\110\100\115")local o=script.Parent repeat wait()until o local M=o local W=M.Humanoid local J=W.RootPart local L W.Running:connect(function(H)if H>W.WalkSpeed/2 then L=true else L=false end end)function getMaterial()local H=W.FloorMaterial if not H then H="\065\105\114"end local o=(string.split(tostring(H),"\069\110\117\109\046\077\097\116\101\114\105\097\108\046"))[2]local M=o return M end local Z runtime.Heartbeat:connect(function()if L then local o=getMaterial()if o~=Z and Z~=nil then H[Z].Playing=false end local M=H[o]M.PlaybackSpeed=W.WalkSpeed/12 M.Playing=true Z=o else for H,o in pairs(H:GetChildren())do o.Playing=false end end end)

local materials = script.Parent:WaitForChild('FootstepSounds')
local plr = script.Parent
repeat wait() until plr
local char = plr
local hum = char.Humanoid
local hrp = hum.RootPart
local walking

hum.Running:connect(function(speed)
	if speed > hum.WalkSpeed/2 then
		walking = true
	else
		walking = false
	end
end)

function getMaterial()
	local floormat = hum.FloorMaterial
	if not floormat then floormat = 'Air' end
	local matstring = string.split(tostring(floormat),'Enum.Material.')[2]
	local material = matstring
	return material
end

local lastmat
runtime.Heartbeat:connect(function()
	if walking then
		local material = getMaterial()
		if material ~= lastmat and lastmat ~= nil then
			materials[lastmat].Playing = false
		end
		local materialSound = materials[material]
		materialSound.PlaybackSpeed = hum.WalkSpeed/12
		materialSound.Playing = true
		lastmat = material
	else
		for _,sound in pairs(materials:GetChildren()) do
			sound.Playing = false
		end
	end
end)
