Tools sound compete glitched

Smart idea, im going to try that right now

this did not work im starting to think i should just re script the tool due to me putting in a another tool and it playing sounds fine

Could you show all of your code and the location of your sound?

Im trying to post my code but its getting “approved” give me a minute.

Strange. That code looks just fine. I’ll have another closer look in a bit.

Sounds like your sounds are not loading, have you tried pre-loading them using contentprovider?

How do I do this? may you explain?

You want to have a table with all the sound IDs you want to pre-load.

local soundsToPreload = {
"rbxassetid://512453452",
"rbxassetid://523446551"
}

Then you will pre-load them using the “PreLoadAsync function”.

local ContentProvider = game:GetService("ContentProvider")
local soundsToPreload = {
"rbxassetid://512453452",
"rbxassetid://523446551"
}

ContentProvider:PreloadAsync(soundToPreload, CallbackFunction)

This callback function is the function that will run once the ids are pre-loaded, You can also just put the “preloadasync” line at the first line of your function also (if there isn’t many sounds to preload)

That would have only caused a delay in the first playback. It should still have played and it would play instantly on subsequent playbacks.

Not always, some assets fail to load in when a game runs due to whatever roblox-related reason, Pre-Loading them will make sure they load in.

Im using the sound object to play the sounds, when I use these tables do I need to create sounds using script to?

No, you don’t need to create new sound objects, you only need to supply the asset IDs within the table.

Then how do I play these sounds?

Normally; You just get the soundobject and :Play() it, The contentprovider pre-loads the sounds just before they are used so they are loaded in and ready to be used.

local sound = game.ReplicatedStorage.Sound
local contentprovider = game:GetService("ContentProvider")
local Table = {sound.SoundId}

local function PlayGunSound()
--other gun stuff here
sound:Play()
end

contentprovider:PreloadAsync(Table, PlayGunSound)

See I dont understand why my other way works on other stutf but not in this script

Here’s a few reasons why it might not work:

  1. You might have only one sound in the “other stuff” so it will more likely load in sucessfully
  2. Maybe the sound itself is not working ? Have you tried playing the preview for it on the roblox website?
  3. The sound may be in the process of moderation (if it has been just uploaded)
  4. The properties on the sound itself might be wrong, check the properties.
  5. You might’ve written it wrong, Again, Here’s how you would do it for a gun:
--define your variables here
local ContentProvider 
local Sound
local Table

local function GunEquip()
    ContentProvider:PreloadAsync(Table)
    --Rest of the script
end

Is the sound being played from a LocalScript or Script?
If it’s from a LocalScript, can you check if SoundService has the ‘RespectFilteringEnabled’ property set to true?

Ive tried playing fromboth nothing works. And I think ‘RespectFilteringEnabled’ is on because all other audios work for like blocks and other tools

Wait so if it works for other tools, then its probably an issue with the actual tool itself.

You think I noticed but no errors or nothing im just trying to remove bits of code and see if it fixes itself