Sound lagging Issue

Hi
Have had this problem for a while now, hopefully time to deal with it and see what I did wrong.

We have a sidescroller game, you collect items and when you touch the item theres a sound that plays every time you pick up the item. The sound is about .41 seconds, and plays back to back. The issue is, the sound lags about a whole 4 seconds before it plays. Ive set the delay to 1 and bellow, but it still lags. I might need to use a sound gate, Ive read the tut on defold website, but I’m unsure as to what exactly I have to do to get it working.

so far I have this for starters. Once the coin is collected, this happens;

	   msg.post("sound#soundgate", "play_gated_sound", {delay = 1, gain = 8})

Before trying to use the gating option, it just sent play_sound and it still lagged.

So I guess the question is, how would I get this code from the website to help my situation;

-- Don't allow the same sound to be played within "gate_time" interval.
local gate_time = 0.3
function init(self)
	-- Store played sound timers in table and count down each frame until they have been
	-- in the table for "gate_time" seconds. Then remove them.
	self.sounds = {}
end
function update(self, dt)
	-- Count down the stored timers
	for k,v in pairs(self.sounds) do
		self.sounds[k] = self.sounds[k] - dt
		if self.sounds[k] < 0 then
			self.sounds[k] = nil
		end
	end
end
function on_message(self, message_id, message, sender)
	if message_id == hash("play_gated_sound") then
		-- Only play sounds that are not currently in the gating table.
		if self.sounds[message.soundcomponent] == nil then
			-- Store sound timer in table
			self.sounds[message.soundcomponent] = gate_time
			-- Redirect the "play_sound" message to the real target
			msg.post(message.soundcomponent, "play_sound", { gain = message.gain })
		else
            -- An attempt to play a sound was gated
			print("gated " .. message.soundcomponent)
		end
	end
end

Thanks!

Are the sound effects oggs or wavs?

theyre ogg

Try wav for sound effects that need to play fast

switched it to .Wav and still having the same issue

So the sound is lagging 4 seconds? Can you isolate the issue down to a single collection, game object and script that plays the sound repeatedly? Does it still lag?