New sounds method, would be useful?

No its not as all sounds TIME_LENGTH would be same as all other sounds COMBINED further more Seprating Load makes it faster

local sound = nil -- your sound here

local t = {
	["walk"] = {2, 0.5} -- sound name = {start pos, length}
}
local function play(n)
	sound.TimePosition = t[n][1]
	sound:Play()
	spawn(function()
		wait(t[n][2])
		sound:Stop()
	end)
end
play("walk")

something I just tried, might be relevant idk (make sure to put it in localscript (to much delay if in serverscript)

It won’t be faster neither would it save time much

even if it does probably would be 0.2-0.7seconds

Yes, like this.
(30 charsss omg)

And im thinking would it be more useful or cheaper instead of uploading every sound.

I actually considered doing this however, there might be issues with possible delay, audio loading, etc. If the audio doesn’t load, all the sound effects wont load, if the audio is delayed, players can hear the other audio at times.

It might be cheaper but it really depends. If you can pull it off well then props, go for it. If there are issues, then you may have a trouble of a time.

I think what you have to decide is how your sounds intertwine with one another.

If the sounds are always going to be played in series no matter the case then you may as well merge them into one sound - this would then reduce the threads time because it doesn’t have to constantly yield for completion to do them in series.

If the sounds are seperately played on a case by case basis e.g. sound for slash of sword, sound for firing of a gun. then its more efficient to have the sounds stored separately and playing them when they become relevant at the time.

Essentially whatever method leads to less maths, yielding and waiting is what you want in the end.

@Theyoloman1920 @megatank58

Not to call you both wrong, but you are wrong due to your reasoning.

In regards to memory, having less sound objects is more efficient but by unnoticeable milliseconds. Every object takes up its own space in the memory, therefore even though the sound data will have the same memory space taken up the additional (repeated) data would cause disparity between the two methods. But these will not matter.

Having them each loaded separately can be both faster and slower in different regards, at the end of the day the assets will get loaded by the server - by having this disjointed the server may load others before another depending on its priority as the server just wants to get the client or itself up and going. You can see in a game when things haven’t completely loaded when you join that the server and client cuts corners when it can to get you in faster, things may get loaded on demand etc.

But to be truthful, you would be saving kilobytes at most so its not even worth the fuss.

What isn’t efficient is having sounds loaded unnecessarily e.g. an ambiance sound in workspace the same ambiance sound loaded in StarterGui - both are not necessary as they would both perform the same necessary function.

Thanks for your response and clearing out my missconfusion appreciate it!

Sooooo… After that what we can to say. Would it be good way to use sounds or nah.

Oh, I see! It totally makes sense now. Thanks, I appreciate it!

As he said the difference is almost unnoticeable or very less

Yes, but is some cases. (30 characters)

For example, i have class/npc with my sounds method, would it be good or no.

I think that Seprate Sounds would be better as they’re more accessible

local id = "rbxassetid://0000000000" -- set id to audio you want

local play
local preload = Instance.new("Sound")
preload.SoundId = id

local t = {
	["walk"] = {2, 0.5} -- name = {start pos, length, [optional] location, [optional] properties}
	--[[ properties
	ie:
		Volume : 5,
		MaxDistance : 10000
	]]
}

game:GetService("ContentProvider"):PreloadAsync({preload}, function(content, status)
	if status == Enum.AssetFetchStatus.Success then
		play = function(n)
			spawn(function()
				local sound = Instance.new("Sound", #t[n] >= 3 and t[n][3] or game:GetService("Workspace"))
				if #t[n] == 4 then
					for i,v in pairs(t[n][4]) do
						sound[i] = v
					end
				end
				sound.SoundId = content
				sound:Play()
				wait(t[n][2] * sound.PlaybackSpeed)
				sound:Stop()
			end)
		end
	else
		warn("Error loading assets")
	end
end)
play("walk")
wait(1)
play("walk")

I made some extra changes:

  • Now preloads sound
  • Plays sound async
  • Can have multiple different sound run at the same time
  • Supports custom properties and locations

Hope these additions help.

Edit: fixed typo where it was preloading the wrong thing

1 Like

Thanks for this (bruh 30 chars help)

idk why, but it wont load. maybe cuz i need wait until use sound or what.

AH IM DUMB, i fixed it i forgot enable http request and etc

wait no, its still wont load any sound