Optimized and Improved Character Sound script

character
sounds

#1

If you're using the default character sound script, I've written a network traffic-optimized version.

File attached:
Sound.rbxmx (11.0 KB)

Source:
http://spotcos.com/Sound.rbxmx

Testing place:
https://www.roblox.com/games/404850188/NeufHumanoidSound

(To use, place the "Sound" script within "StarterPlayer/StarterCharacterScripts")

This problem came from @alexnewtron's 100-player meepcity servers, they were having network bandwidth problems with the "new sound code" enabled.

The old default sound code sent a bunch of unnecessary replication traffic. This new code, in the "worst case scenario" (a player repeatedly jumping up an upwards slope) should be up to 6x less network traffic, while behaving almost exactly the same to to player.

Anyway, try it out and let me know if you've got any comments.
This will be the new default within a few weeks.


#2

Sweet! I am looking forward to any optmizations that benefit 100 player servers.


#3

its live as the default


#4

One small thing I gotta poke at real quick.
The old version of the sound script used to scale the pitch based on the user's movement speed, but this doesn't appear to be the case anymore.


#5

this is actually intentional.
it causes a lot of unnecessary (if you consider this feature unnecessary) network traffic when not filtering enabled.
its normally not very noticeable too, and just sounds "strange" when moving up slopes.


#6

Does this code only effect the characters humanoid? What about sounds in workspace or something.


#7

It only affects character sounds. Characters come with a sound script (unless overwritten in StarterCharacterScripts) that handles the sounds for walking, falling, swimming, dying, etc. Any sounds not handled by that script are unaffected.


#8

Update: I've got some minor changes I'd like to make to the humanoid sound scripts.

  1. I'd like to split the "footsteps" sound into the actual individual steps. This would be the "correct" fix to the humanoid walkspeed sound problem.

  2. I'd like to fix the swimming sound to loop better. There's a noticeable gap in it.

If anyone's already solved these problems and would like to contribute your work please let me know :slight_smile:


#9

"I'd like to split the "footsteps" sound into the actual individual steps."

It'd waaay cool if in the future this was taken advantage of to change footstep sounds to reflect the material being walked on


#10

I'd also like to try a few experimental things once "Audio Effects" are out (which will be soon? pending some design decisions).

Again, if you've got anything you'd like to contribute (because I know a bunch of games implement this themselves) we could make this dream a reality :slight_smile:


#11

I have a bunch of footstep sounds Ive recorded for my game. I modeled my footstep sound script after roblox's so everything is in a 1 sec loop, however I still have the original files.

Do you have an email address? I can send you my audio.


#12

If you separate the footstep sounds, please also remove that awful one with the creaking noise.


#13

Something I noticed is that the script won't work as intended (without modification) if the Humanoid is renamed.

Here is an idea to make it more universal:

while not Humanoid do
	for _,NewHumanoid in pairs(Figure:GetChildren()) do
		if NewHumanoid:IsA("Humanoid") then
			Humanoid = NewHumanoid
			break
		end
	end
	wait()
end

#14

Or make it get used when stepping on woodplanks?


#15

pmed


#16

great, ill make that change


#17

Once Instance::FindFirstChildOfClass() is enabled in a few weeks that can be simplified to:

local Humanoid = Figure:FindFirstChildOfClass("Humanoid")
while not Humanoid do
	Figure.ChildAdded:wait()
	Humanoid = Figure:FindFirstChildOfClass("Humanoid")
end

#18

Fixed some spelling/grammar mistakes and removing v1/v2 sound mode check as well.


#19

Yay! No more creating GetHumanoid functions!