Hello, Developers
I need help with scripting walking sounds, I want to know how to script so that walking sound is different on each material, there is no tutorial on YouTube so,
reply if you know solution. Thank you.
Hello, Developers
I need help with scripting walking sounds, I want to know how to script so that walking sound is different on each material, there is no tutorial on YouTube so,
reply if you know solution. Thank you.
To get the part that the player is standing on, just cast a ray and check what material the part is.
local ray = Ray.new(humanoidRootPart.Position, Vector3.new(0, -3, 0))
local floor = workspace:FindPartOnRay(ray, character) --ignore the player's character
if floor then
--check material of floor
end
You’ll want to check out Humanoid.FloorMaterial. You can use that property to see which material the player is standing on, if any. If it’s not enough to have different footstep sounds for each material, you’ll want to do as Fualtsified suggested and do a raycast to figure out which specific part the player is standing on.
Use the Humanoid.FloorMaterial property to see what the player is standing on and change the Running ID accordingly.
This is an example for default materials:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local DefaultSound = Character.Head:WaitForChild("Running").SoundId
local MaterialTable = {
[Enum.Material.Plastic] = 315915457
}
game:GetService("ContentProvider"):PreloadAsync(315915457)
Character.Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
local FloorMaterial = Character.Humanoid.FloorMaterial
if MaterialTable[FloorMaterial] then
Character.Head.Running.SoundId = MaterialTable[FloorMaterial]
else
Character.Head.Running.SoundId = DefaultSound
end
end)
EDIT: Forgotten to put in Enum.Material
Script in workspace?
No this goes into StarterCharacterScripts
I wanna make grass sounds, where do I put grass
You’d put grass into the array like this:
local MaterialTable = {
["Wood"] = 0,
["Concrete"] = 0,
["Grass"] = 0, -- Your ID replaces 0
}
EDIT: Remove the comma on the last array
there is a line on
Grass on left of ‘’
Yeah sorry, remove the comma at the end of the Grass Line. Also, make sure, if you’re not making the Wood or Concrete as custom sounds then you should remove it from the MaterialTable
LocalScript, StarterCharacterScripts.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local DefaultSound = Character.Head:WaitForChild("Running").SoundId
local MaterialTable = {
[Enum.Material.Grass] = "rbxassetid://256575709"
}
local Assets = {"rbxassetid://256575709","rbxassetid://256575709"}
game:GetService("ContentProvider"):PreloadAsync(Assets)
Character.Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
local FloorMaterial = Character.Humanoid.FloorMaterial
if MaterialTable[FloorMaterial] then
Character.Head.Running.SoundId = MaterialTable[FloorMaterial]
else
Character.Head.Running.SoundId = DefaultSound
end
end)
Not too much?
also do you know script for jumping sound, just that please?
As long your audio is heard
can you do last thing for me jumping animation?
i mean sound
Could you mark the Thread as the solution so people know what the actual solution is
Also, unfortunately I can’t help too much because you need to learn a bit for your self . We have to start somewhere. But to change the jumping sound is in the Head object under the Player
okay thanks
I’d like to remind you that the Scripting Support category is not an outlet for asking for code. It’s nice to see that you’re learning and all, but try and achieve some of these things alone or look around to see how you can accomplish it. YouTube tutorials are not the only way - there are many other resources available to attempt these problems.