I am currently working on a series of guns for my game, for the sounds to sound good i need to clone the firing sound and play them whenever the gun is firing, however the cloned sounds don't seem to be preloading and the gun sounds horrible. How can I fix this?
I feel as the code for this should be fairly obvious but here is the code anyway
local sound= game.ReplicatedStorage.Weapons[ PlayerEWeapons[plr.Name]].FireSound:Clone()-- "PlayerEWeapons[plr.Name]" is the equipped weapon of the player sound.Parent=plr.Character.Head spawn(function() sound:Play() wait(sound.TimeLength) sound:Destroy() end)
here is my preloading code:
local contp=game:GetService("ContentProvider") local assets={} script.Parent.Loading.State.Text="Fetching Sounds to be loaded" for i,v in pairs(game.ReplicatedStorage:GetDescendants())do if v:IsA("Sound")then contp:PreloadAsync({v},function()end) end end function LoadedAsset(contentid,sucsess) script.Parent.Loading.Asset.Text=contentid.."was loaded" end script.Parent.Loading:Destroy()