Default LocalSound script doesn't nil-check something it probably should

Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.

In LocalSound, a default character script, a nil-check is missing on line 241:

...
		[Enum.HumanoidStateType.Swimming] = function(speed)
		    local threshold = speed
			if activeState ~= Enum.HumanoidStateType.Swimming and threshold > 0.1 then -- Line 241 as of now
				local splashSound = Sounds[SFX.Splash]
				splashSound.Volume = Util.Clamp(
...

speed/threshold can be nil here. All other cases, such as this one, simply check if the value is nil too, so apparently it’s expected that the value can be nil (I think?):

...
		[Enum.HumanoidStateType.Climbing] = function(speed)
			local sound = Sounds[SFX.Climbing]
            if speed ~= nil and math.abs(speed) > 0.1 then
                Util.Resume(sound)
                stopPlayingLoopedSoundsExcept(sound)
...

This causes a pretty large amount of errors in my games. Typically when players exit water this may occur.

How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.

Doesn’t always happen, but often enough that my error logs are primarily this error. Only seems to happen when exiting water.

Where does the bug happen (www, gametest, etc) Is it level-specific? Is it game specific? Please post a link to the place that exhibits the issue.

Live

Would a screenshot or video help describe it to someone? If so, post one.

n/a

For graphics bugs, it is sometimes helpful to know your system specs, especially graphics card.

n/a

When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.

Been an issue for a long time.

Anything else that you would want to know about the bug if it were your job to find and fix it.

n/a

3 Likes