How can I create a footsteps table with categories of each material?

I’ve been trying to do this but I just can’t it seems very hard.

There is a property in a humanoid called floormaterial, don’t know if that’s what you need.

press CTRL + F then search for floormaterial, it will show you the one I’m talking about.

If you want to change the footsteps when on different materials, let’s say you’re stepping on grass and you want to make sounds of stepping on grass

Play a sound when the player moves with WASD, use contextactionservice or use the humanoids movedirection.
Make a table like listofpieces = {}, add Enum.Material.Grass or whatever else you want to use as the name of the dictionary

So, like

Sfx = {[Enum.Material.Grass] = script.GrassSound, 
       [Enum.Material.Pebble] = script.RockSound}

and so on. The script this is happening in has sounds as children for each sound of footstep used.

Then, when the value of movedirection changes, play the sound until movedirection is equal to vector3.new(0, 0, 0), if movedirection is equal to 0, 0, 0 stop the sound.

How does it know what to play? you do “Sfx[Humanoid.FloorMaterial]:Play()”, it will try to find the floormaterial currently being stepped on and will try to play it. You would also need to do a quick verification that the floormaterial has a sound equivalent of it, it will get an error if the material doesn’t have a sound. “if Sfx[Humanoid.FloorMaterial] then” would have to be before playing the sound.

Something like this, I would go this way.

2 Likes

@FranSauce’s solution may work, I have never tried it. The only downside is you’d have to constantly check the FloorMaterial, but you’d have to do that with most solutions.

You could always attempt to do raycasts downward. Just check the material of the part it hits (if it hits anything), and apply the changes as needed. I have no idea how this would do for performance, but it could work

No no, not constantly change, just use the value.changed that fires when the value is changed. There’s a difference there, like USB keyboards vs PS/2 keyboards.

That’s a fair point, totally forgot that existed. Thanks for clarifying!

Will it work when it plant material or color on the ground to show material/color on it?

Floor material only detects floor material, not color. So I believe it wouldnt be useful for color since it doesn’t detect that.

1 Like

Hi @Kayer72 I didn’t create the code but, a lot of game are using this script,
is also very simple to understood, so im going to share it for you in this baseplate
In the future you can go to improve it or add new materials
Link: Baseplate_Sound.rbxl (30,0 KB)

1 Like