--


Humanoid.Changed:Connect(function()
if Enum.Material[Humanoid.FloorMaterial.Name] then
script.Parent.CurrentMaterial.Value = Humanoid.FloorMaterial.Name
else
script.Parent.CurrentMaterial.Value = DefaultSound
end
end)

function TurnOffSounds()
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Sound" then
v.Playing = false	
end	
end		
end

function MakeSound()
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Sound" then
if v.Name ~= script.Parent.CurrentMaterial.Value then
v.Playing = false	
else
if script.Parent.CurrentMaterial.Value  == 'Air' and ToggleAirSound == true then	
v.Playing = true	
v.PlaybackSpeed = Humanoid.WalkSpeed / 12
else
if v.Name ~= 'Air' then
v.Playing = true	
v.PlaybackSpeed = Humanoid.WalkSpeed / 12	
end	
end
end		
end
end
end

function MakeDefaultSound()
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Sound" then
if v.Name ~= DefaultSound then
v.Playing = false	
else
v.Playing = true	
v.PlaybackSpeed = Humanoid.WalkSpeed / 12	
end		
end
end
end

while wait(1/10) do
local Moving = Humanoid.MoveDirection ~= Vector3.new(0,0,0)
if Moving then
if script.Parent:FindFirstChild(script.Parent.CurrentMaterial.Value) and script.Parent.CurrentMaterial.Value ~= nil then	
MakeSound()
else	
MakeDefaultSound()	
end		
else		
TurnOffSounds()	
end	
end
