From a7eac93d5dd8154a0cede3869735d2e93c61e7c1 Mon Sep 17 00:00:00 2001 From: VCRhythm Date: Fri, 16 Oct 2026 18:31:00 -0400 Subject: [PATCH] Preload plugin sounds as Sound instances preloadAssets handed every string in Assets to ContentProvider:PreloadAsync, which fetches a bare string as an image. The Notification sound (rbxassetid://203785492) therefore failed with "Asset type does not match requested type" in Studio's output each time the plugin loaded. Everything under Assets.Sounds is now preloaded as a Sound instance, which loads its SoundId as audio; all other assets are preloaded as before. Fixes #1342 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NYrG5tMSJQyEynTw6Uwhcx --- plugin/src/preloadAssets.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/plugin/src/preloadAssets.lua b/plugin/src/preloadAssets.lua index 47c6d40b..d7501e42 100644 --- a/plugin/src/preloadAssets.lua +++ b/plugin/src/preloadAssets.lua @@ -21,12 +21,38 @@ function gatherAssetUrlsRecursive(currentTable, currentUrls) end local function preloadAssets() - local contentUrls = gatherAssetUrlsRecursive(Assets) + local contentUrls = {} + local soundUrls = {} + + for key, value in Assets do + if key == "Sounds" then + gatherAssetUrlsRecursive(value, soundUrls) + elseif typeof(value) == "string" then + table.insert(contentUrls, value) + elseif typeof(value) == "table" then + gatherAssetUrlsRecursive(value, contentUrls) + end + end Log.trace("Preloading assets: {:?}", contentUrls) + Log.trace("Preloading sounds: {:?}", soundUrls) + + -- PreloadAsync fetches a bare string as an image, so sounds go in as Sound + -- instances, which load their SoundId as audio. + local preloadList = table.clone(contentUrls) + local sounds = {} + for _, soundId in soundUrls do + local sound = Instance.new("Sound") + sound.SoundId = soundId + table.insert(sounds, sound) + table.insert(preloadList, sound) + end coroutine.wrap(function() - ContentProvider:PreloadAsync(contentUrls) + ContentProvider:PreloadAsync(preloadList) + for _, sound in sounds do + sound:Destroy() + end end)() end