✓ Accepted answer
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
repeat wait() until Character and game:IsLoaded()
local Humanoid = Character.Humanoid
local HumanoidRootPart = Character.HumanoidRootPart
local RunningSound = HumanoidRootPart.Running
local OldSoundID, OldSoundVol
OldSoundID = RunningSound.SoundId
OldSoundVol = RunningSound.Volume
local MaterialTypes = {
['Glass'] = Enum.Material.Glass;
['Sand'] = Enum.Material.Sand;
['Wood'] = Enum.Material.Wood;
['Rock'] = Enum.Material.Rock;
}
local CheckIfMaterial = function(Material)
if Humanoid.FloorMaterial == Material then
return true
end
return false
end
Humanoid:GetPropertyChangedSignal('FloorMaterial'):Connect(function()
if CheckIfMaterial(MaterialTypes.Glass) or CheckIfMaterial(MaterialTypes.Sand) then
RunningSound.SoundId = "rbxassetid://510933218"
RunningSound.Volume = 1
elseif CheckIfMaterial(MaterialTypes.Wood) or CheckIfMaterial(MaterialTypes.Rock) then
RunningSound.SoundId = "rbxassetid://2991635108"
RunningSound.Volume = .1
else
RunningSound.SoundId = OldSoundID
RunningSound.Volume = OldSoundVol
end
end)
I've tested this and works perfectly according to what you needed to be fixed and what you wanted. Keep notes of this code and remember that there's events for the Humanoid which can make your process 10x easier and far more efficient. See you around, have a nice day.
Although i'm sorry this could've been much more simplified but i was bored and tired at the time, might update it later.