local o=script.Parent:WaitForChild("\070\111\111\116\115\116\101\112\083\111\117\110\100\115")local p=script.Parent repeat wait()until p local O=p local K=O.Humanoid local T=K.RootPart local y K.Running:connect(function(o)if o>K.WalkSpeed/2 then y=true else y=false end end)function getMaterial()local o=script.Parent.Head.Footstep end local a local D=false runtime.Heartbeat:connect(function()if y and D==false then local p=getMaterial()if p~=a and a~=nil then o[a].Playing=false end local O=o[p]:Clone()O.Playing=true a=p D=true wait(1.5)D=false O:Destroy()else for o,p in pairs(o:GetChildren())do p.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 material = script.Parent.Head.Footstep
end

local lastmat
local debounce = false
runtime.Heartbeat:connect(function()
	if walking and debounce == false then
		local material = getMaterial()
		if material ~= lastmat and lastmat ~= nil then
			materials[lastmat].Playing = false
		end
		local materialSound = materials[material]:Clone()
		materialSound.Playing = true
		lastmat = material
		debounce = true
		wait(1.5)
		debounce = false
		materialSound:Destroy()
	else
		for _,sound in pairs(materials:GetChildren()) do
			sound.Playing = false
		end
	end
end)
