So I am creating a gun and everything seems to work except the sound. The gun shooting sound doesn’t play after being played 10 times (after 1 mag)
I’ve tried using ContentProvider but that doesn’t seem to work.
Here’s the code for the ContentProvider:
local ContentProvider = game:GetService("ContentProvider")
local sounds = {}
for _, v in ipairs(weapon:GetDescendants()) do
if v:isA("Sound") then
table.insert(sounds,v)
end
end
ContentProvider:PreloadAsync(sounds)
Here is the video:
Am I doing something wrong? If I am can someone please tell me how to fix it?
A couple questions for you. How are you using Content provider? Are you loading after each shot? Or each set of 10 shots? Or once overall? (Seeing that code I am assuming once, but you could have wrapped it in a function to be called more then once) I used content provider and have only needed for it to run once for it to load. An idea too, is to load the SoundId instead of the Sound Instance, by changing it to table.insert(sounds,v.SoundId). I also know roblox studio acts weird and just does an infinite yield in the Studio test, but works fine in roblox player (still need a solution to this for me. I’m not sure why yet… Maybe its a group owned game or a Team created experience that causes this? I really don’t know why)
Let me know the answer to these. Also sharing more of your script can be useful!