Sound-Category API
loadCategory
Ensures all sounds in a specified Sound-Category are loaded into ReplicatedStorage.
Function:
function loadCategory<C extends SoundCategory>(category: C): void;
Usage:
SoundCategories.loadCategory("Menu");
playCategory
Plays all sounds within a specified Sound-Category.
Function:
function playCategory<C extends SoundCategory>(category: C): void;
Usage:
SoundCategories.playCategory("Menu");
stopCategory
Stops all sounds within a specified Sound-Category.
Function:
function stopCategory<C extends SoundCategory>(category: C): void;
Usage:
SoundCategories.stopCategory("Menu");
stopAllCategories
Stops all sounds within all Sound-Categories.
Function:
function stopAllCategories(): void;
Usage:
SoundCategories.stopAllCategories();
setCategoryVolume
Sets the volume for all sounds within a specified Sound-Category.
Function:
function setCategoryVolume<C extends SoundCategory>(category: C, volume: number): void;
Usage:
SoundCategories.setCategoryVolume("Menu", 0.5);
setGlobalCategoryVolume
Sets the global volume for all categories.
Function:
function setGlobalCategoryVolume(volume: number): void;
Usage:
SoundCategories.setGlobalCategoryVolume(0.8);
isCategoryPlaying
Checks if all sounds in a category are currently playing.
Function:
function isCategoryPlaying<C extends SoundCategory>(category: C): boolean;
Usage:
const playing = SoundCategories.isCategoryPlaying("Menu");
playSoundFromCategory
Plays a specific sound from a category. Autocompletion ensures only valid sound names can be used.
Function:
function playSoundFromCategory<C extends SoundCategory, S extends keyof T[C]["sounds"]>(category: C, sound: S): void;
Usage:
SoundCategories.playSoundFromCategory("Menu", "Click");
resetCategory
Resets all sounds in a category to their starting position.
Function:
function resetCategory<C extends SoundCategory>(category: C): void;
Usage:
SoundCategories.resetCategory("Menu");
resetAllCategories
Resets all sounds in all categories to their starting position.
Function:
function resetAllCategories(): void;
Usage:
SoundCategories.resetAllCategories();
preloadCategory
Preloads all sounds in a category.
Function:
function preloadCategory<C extends SoundCategory>(category: C): void;
Usage:
SoundCategories.preloadCategory("Menu");
preloadAllCategories
Preloads all sounds in all categories.
Function:
function preloadAllCategories(): void;
Usage:
SoundCategories.preloadAllCategories();
fadeInCategory
Gradually increases the volume of all sounds in a category over a duration.
Function:
function fadeInCategory<C extends SoundCategory>(category: C, duration: number, volume: number): void;
Usage:
SoundCategories.fadeInCategory("Menu", 2, 1);
fadeOutCategory
Gradually decreases the volume of all sounds in a category over a duration, optionally stopping them at zero.
Function:
function fadeOutCategory<C extends SoundCategory>(category: C, duration: number, targetVolume?: number): void;
Usage:
SoundCategories.fadeOutCategory("Menu", 2);
onCategoryEnd
Registers a callback to be executed when all sounds in a category finish playing.
Function:
function onCategoryEnd<C extends SoundCategory>(category: C, callback: () => void): void;
Usage:
SoundCategories.onCategoryEnd("Menu", () => {
print("All Menu sounds finished!");
});