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

Custom Running Sound Is Not Playing?

Asked by 3 years ago

I created this script to change the player's footstep sounds based on what material they are on. To make it server sided I had to create my own custom sound. For some reason my script isn't working and the new running sound won't play at all.

local materialSounds = {

    [Enum.Material.DiamondPlate] = game.ServerStorage.Sounds:WaitForChild("DiamondPlate").SoundId,
    [Enum.Material.Glass] =  game.ServerStorage.Sounds:WaitForChild("Glass").SoundId,
    [Enum.Material.Grass] =  game.ServerStorage.Sounds:WaitForChild("Grass").SoundId,
    [Enum.Material.Ice] =  game.ServerStorage.Sounds:WaitForChild("Ice").SoundId,
    [Enum.Material.Metal] =  game.ServerStorage.Sounds:WaitForChild("Metal").SoundId,
    [Enum.Material.Wood] =  game.ServerStorage.Sounds:WaitForChild("Wood").SoundId,
    [Enum.Material.SmoothPlastic] = game.ServerStorage.Sounds:WaitForChild("SmoothPlastic").SoundId,
    [Enum.Material.Sand] = game.ServerStorage.Sounds:WaitForChild("Sand").SoundId,
    [Enum.Material.Concrete] = game.ServerStorage.Sounds:WaitForChild("Concrete").SoundId,
    [Enum.Material.Granite] = game.ServerStorage.Sounds:WaitForChild("Granite").SoundId

}

game.Players.PlayerAdded:Connect(function (plr)
    plr.CharacterAdded:Connect(function (char)
        local hum = char:WaitForChild("Humanoid")
        local hrp = char:WaitForChild("HumanoidRootPart")
        local Running1 = game.ServerStorage.Sounds.SmoothPlastic:Clone()
        Running1.Parent = hrp
        hum.Running:Connect(function ()
            if hum:GetState() == Enum.HumanoidStateType.Running then
                Running1.Playing = true
                Running1:Play()
                print("YO MAMA ES FAT")
            end

        end)


        hum:GetPropertyChangedSignal("FloorMaterial"):Connect(function ()

            local floorMat = hum.FloorMaterial
            local floorSound = materialSounds[floorMat]
            print("Mat Changed")
            if floorSound then
                --soundE:FireServer(floorSound, materialSounds, true)
                Running1.SoundId = floorSound

            else
                --soundE:FireServer(footSounds, materialSounds, false)
                Running1.SoundId = materialSounds[Enum.Material.SmoothPlastic]

            end
        end)
    end)

end)


Answer this question