Thanks for telling me a new information.
How would i do this with terrain?
EDIT: Turns out FloorMaterial is suppose to detect terrain, but doesnât
The Humanoid does detect FloorMaterial but is sometimes buggy.
Try this model I made a while back using this thread and other tutorials.
TerrainSound.rbxm (3.5 KB)
No, this doesnât really matter much. This error means that Studio is unable to load the texture ID of your material, but as long as you can actually see the material when you play, then this error should not be breaking your gameplay.
Well FloorMaterial works on terrain for me. I made a script that uses FloorMaterial and it works fine on terrain
I said that over a year ago. This issue has been fixed several months ago
Character sounds are no longer parented to the characterâs head, to accommodate for that change I wrote the following.
local players = game:GetService"Players"
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild"Humanoid"
if not humanoid.RootPart then humanoid:GetPropertyChangedSignal"RootPart":Wait() end
local root = humanoid.RootPart
local running = root:WaitForChild("Running")
local materialSounds = {
["Air"] = "", --Paste sound IDs here.
["Asphalt"] = "",
["Basalt"] = "",
["Brick"] = "",
["Cobblestone"] = "",
["Concrete"] = "",
["CorrodedMetal"] = "",
["CrackedLava"] = "",
["DiamondPlate"] = "",
["Fabric"] = "",
["Foil"] = "",
["ForceField"] = "",
["Glacier"] = "",
["Glass"] = "",
["Granite"] = "",
["Grass"] = "",
["Ground"] = "",
["Ice"] = "",
["LeafyGrass"] = "",
["Limestone"] = "",
["Marble"] = "",
["Metal"] = "",
["Mud"] = "",
["Neon"] = "",
["Pavement"] = "",
["Pebble"] = "",
["Plastic"] = "",
["Rock"] = "",
["Salt"] = "",
["Sand"] = "",
["Sandstone"] = "",
["Slate"] = "",
["SmoothPlastic"] = "",
["Snow"] = "",
["Water"] = "",
["Wood"] = "",
["WoodPlanks"] = ""
}
local function onFloorMaterialChanged()
if humanoid.FloorMaterial then
running.SoundId = materialSounds[humanoid.FloorMaterial.Name]
else
running.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3" --Default running sound.
end
end
local floorMaterialChanged = humanoid:GetPropertyChangedSignal"FloorMaterial"
floorMaterialChanged:Connect(onFloorMaterialChanged)
Thank you! i was trying to make it work and failed