Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can i use floormaterial for materialvariants?

Asked by 1 year ago

so my code is:

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 = {
    ["GrassVariant"] = "rbxassetid://11736488101"
}

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)

I am trying to make it so that there are different sounds for walking on different materialvariants (they all look like smoothplastic, and are under the smoothplastic material). Any way I could make floormaterial work with checking material variants?

Answer this question