Footstep sound changer by material

Hello there, I have come to you open sourcing one of my projects.

I have come open sourcing it for the reason of many people asking me for it, so I will redirect them to this post right here on ConnectDev.

To start off, you will need to have few materials on your map. Any material such, plastic, grass, air, brick etc…
When that’s ready you will need to create a SoundGroup object placed in SoundService called Footsteps.
Such displayed below

Then, we would want to make our sounds. So, to achieve that, you will need to create sounds in the SoundGroup object named the material name then set the SoundId to your sound’s Id.
Here’s an example of what I have in my game.

Also make sure to set a Sound called “nil Sound” for that will make no sound when your material does not exist in the Footsteps SoundGroup

After that is setup, we are ready to code! Yay!

So for the coding section, start off by placing a LocalScript in StarterCharacterScripts (name does not matter). So if you are not aware, there is a Sound set in the HumanoidRootPart by Roblox which is used for the character’s footsteps.

Then you would paste in this code below in the LocalScript.

local Character = script.Parent;
local HumanoidRoot = Character:WaitForChild("HumanoidRootPart");
local RunningSound = HumanoidRoot:WaitForChild("Running");
local FootstepsSoundGroup = game:GetService("SoundService"):WaitForChild("Footsteps");
local Humanoid = Character:WaitForChild("Humanoid");

	if (prop == "FloorMaterial") then			
		if (FootstepsSoundGroup:FindFirstChild(Humanoid.FloorMaterial) == nil) then
			RunningSound.SoundId = FootstepsSoundGroup:WaitForChild("nil Sound").SoundId;
			RunningSound.PlaybackSpeed = FootstepsSoundGroup:WaitForChild("nil Sound").PlaybackSpeed;
			RunningSound.Volume = FootstepsSoundGroup:WaitForChild("nil Sound").Volume;
			RunningSound.SoundId = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).SoundId ;
			RunningSound.PlaybackSpeed = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).PlaybackSpeed;
			RunningSound.Volume = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).Volume;
			print(Humanoid.FloorMaterial); --Checking

Hope this has contributed to your development :wink:
Crediting me is not needed.

Brief overview on what you must know to achieve

So this section is used if you were wanting to understand the code in detail.

First off, you must know that the HumanoidRootPart has sounds in it when game runs.
There are a few sounds in there, but no need to worry. We’re just concentrating on the Running one currently.

The Humanoid has a property which indicates it’s current material it is standing on. I have used that to detect which part the Humanoid is standing on with a changed event which fires every time a property in the Humanoid changes.

    if prop == "FloorMaterial" then

That would be basically what is the main part of my code. As for the rest is just getting the sound Id from the SoundGroup and setting it to the HumanoidRootPart’s Running Sound Id.

If you have any suggestions, let me know :slight_smile:


This could be a good model, you can make walking sounds for certain terrains and add it into a model, after that i could advertise the model for you.

Ooo I appreciate the offer, but I don’t really think I would want to advertise something like this as it’s nothing too broadly used in games.
I really like your suggestion making into a model, I’ll do that now.

This actually is really nice. Never understood the reason for “SoundService”! :laughing:

1 Like

dawg!!! he ll yeah!!!

1 Like

Welcome to the community