Audio
PM.Audio attaches stock audio presets to a part. The game ships a library of audio presets (engine sounds, mechanical sounds, and so on), and this module binds one to a part without you having to build the audio module by hand. It is the smallest typed module: one helper.
Ensuring a preset
PM.Audio:EnsurePreset(part, presetId, targetTransformPath, overrideExistingAudio) makes sure the part has the hidden audio-preset module and that it carries a binding for the given preset.
PM.Parts:Patch("GiveEngineSound")
:Named("engine_1v_methalox_terrier")
:Do(function(part)
PM.Audio:EnsurePreset(part, "SomeStockEnginePreset")
end)The arguments:
partis the part you are patching, the value from yourDocallback.presetIdis the stock preset to bind.targetTransformPathis optional. It points the audio at a specific transform on the part when the sound should come from a particular spot rather than the part as a whole.overrideExistingAudiois optional. Set ittrueto replace audio the part already has rather than leaving existing bindings in place.
When to use it
Use this when a part is missing a sound it should have, or when you want to swap in a different stock preset. Because it is an Ensure, it is safe to run on a part that may or may not already have the audio module: it adds the module if needed and binds the preset either way. The set of preset ids comes from the game's audio library.