Sound not playing, but other sound is playing. No error in the Output?

Hello all !

So, I have a script that plays a sound when you jump and plays a sound when you land.

Unfortunately, the jump sound wont work, but the land sound will, I don’t know why and I am stuck on finding a solution for this.

Here is the script:

local char = script.Parent
local humanoid = char:FindFirstChild("Humanoid")
local spinballmodule = require(game:GetService("ReplicatedStorage").MechanismModule.SpinBallJump)

local jumpSound = char:WaitForChild("sound1")
local landSound = char:WaitForChild("sound2")

humanoid.StateChanged:Connect(function(newstate)
	if newstate == Enum.HumanoidStateType.Jumping then
		spinballmodule.CreateSpinJump()
		jumpSound:Play()
	elseif newstate == Enum.HumanoidStateType.Landed then
		spinballmodule.DestroySpinJump()
		landSound:Play()
	end
end)

Video showcasing the landing sound only working:
robloxapp-20221230-1531090.wmv (1.7 MB)

Any help on this? Very confused.

I remember doing something similar a while back, and I had some issues with the states. Try printing the state and see which state is registered when the character jumps (I believe it is “FreeFalling” or something along those lines).

1 Like

This works but it just makes the sound play twice when jumping.

I will try to play the sound over the module script I am requiring, maybe that will work. Just thought about this.

You can add a debounce to require the character to land before playing it again, or some other tweaks. Its a bit of a patch work, but if I recall correctly the humanoid states aren’t really working as intended.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.