--|| SERVICES ||--

local RunService = game:GetService("RunService")

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")

local Database = require(script.SoundsData)

local soundConnection
local stepInterval = 0.1
local lastStep = tick()

local Sound = Instance.new("Sound")
Sound.MaxDistance = 150
Sound.Looped = true
Sound.Name = "Material Walking Sound"
Sound.Parent = Character.HumanoidRootPart

Humanoid.Running:Connect(function(Speed)
	if Speed > 0 then
		if not Sound.IsPlaying then
			Sound:Play()
		end
	else
		Sound:Stop()
	end
end)

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	if Database[Humanoid.FloorMaterial] then
		Sound.SoundId = Database[Humanoid.FloorMaterial]
	end
end)
