function CharacterRealism.MountMaterialSounds(a,l)local d=l.Parent local u=d and d:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116",10)if not(u and u:IsA("\066\097\115\101\080\097\114\116"))then return end Util:PromiseChild(u,"\082\117\110\110\105\110\103",function(d)if not d:IsA("\083\111\117\110\100")then return end local n=Instance.new("\078\117\109\098\101\114\086\097\108\117\101")n.Name="\079\108\100\080\105\116\099\104"n.Parent=d n.Value=1 local function K(a,K)if K.Name:find("\082\117\110\110\105\110\103")then while l:GetState()==K do local a=l.HipHeight if l.RigType.Name=="\082\054"then a=2.8 end local K=a/3 local X=(u.Velocity*XZ_VECTOR3).Magnitude local U=((X-4)/12)*K d.Volume=math.clamp(U,0,1)local E=n.Value/((K*15)/X)d.Pitch=E RunService.Heartbeat:Wait()end end end local function X()local u=a.Sounds.Concrete local n=l.FloorMaterial.Name if not a.Sounds[n]then if not a.MaterialMap[n]then n=a.Sounds.Concrete else n=a.MaterialMap[n]end end if a.Sounds[n]then u=a.Sounds[n]end d.SoundId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..u end local U=l:GetPropertyChangedSignal("\070\108\111\111\114\077\097\116\101\114\105\097\108")U:Connect(X)d.EmitterSize=1 d.MaxDistance=50 X()l.StateChanged:Connect(K)K(nil,Enum.HumanoidStateType.Running)end)end


function CharacterRealism:MountMaterialSounds(humanoid)
	local character = humanoid.Parent
	local rootPart = character and character:WaitForChild("HumanoidRootPart", 10)
	
	if not (rootPart and rootPart:IsA("BasePart")) then
		return
	end
	
	Util:PromiseChild(rootPart, "Running", function (running)
		if not running:IsA("Sound") then
			return
		end
		
		local oldPitch = Instance.new("NumberValue")
		oldPitch.Name = "OldPitch"
		oldPitch.Parent = running
		oldPitch.Value = 1
		
		local function onStateChanged(old, new)			
			if new.Name:find("Running") then
				while humanoid:GetState() == new do
					local hipHeight = humanoid.HipHeight
					
					if humanoid.RigType.Name == "R6" then
						hipHeight = 2.8
					end
					
					local scale = hipHeight / 3
					local speed = (rootPart.Velocity * XZ_VECTOR3).Magnitude
					
					local volume = ((speed - 4) / 12) * scale
					running.Volume = math.clamp(volume, 0, 1)
					
					local pitch = oldPitch.Value / ((scale * 15) / speed)
					running.Pitch = pitch
					
					RunService.Heartbeat:Wait()
				end	
			end
		end
		
		local function updateRunningSoundId()
			local soundId = self.Sounds.Concrete
			local material = humanoid.FloorMaterial.Name
			
			if not self.Sounds[material] then
				if not self.MaterialMap[material] then
					material = self.Sounds.Concrete
				else
					material = self.MaterialMap[material]
				end
			end
			
			if self.Sounds[material] then
				soundId = self.Sounds[material]
			end
			
			running.SoundId = "rbxassetid://" .. soundId
		end
		
		local floorListener = humanoid:GetPropertyChangedSignal("FloorMaterial")
		floorListener:Connect(updateRunningSoundId)
		
		running.EmitterSize = 1
		running.MaxDistance = 50
		
		updateRunningSoundId()
		humanoid.StateChanged:Connect(onStateChanged)
		
		onStateChanged(nil, Enum.HumanoidStateType.Running)
	end)
end
