How do you make the camera shake when you jump?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When the player jumps and hits the ground the camera shakes
  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to do this.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked on YouTube and here and I still cant solve this problem.

Use Humanoid.StateChanged to detect whenever the player has landed by checking if the new state argument (the second one) is equal to HumanoidStateType.Landed (as this fires whenever the player, well, lands on a surface), and use a module or script to produce the shake (e.g EZShake)

1 Like

Just a quick question. The script that will do this should be in startercharacterscripts right?

yes it should be in starter playercharacter scripts but put it in a script that controls players states if you have one

ok thanks for helping me i really appreciate it.

Scripts the control the players character client side should always be placed in starter player scripts

glad to be of help, please mark his answer as the solution.

I need help. I was just doing a test.

I’ve tried this but it doesnt work

local humanoid = script.Parent.Humanoid

humanoid.StateChanged:Connect(function(oldstate, newstate)
if newstate.Enum.HumanoidStateType.Landed then
print(“Starting Camera Shake”)
end

end)

it keeps saying this in the output Enum is not a valid member of “Enum.HumanoidStateType.Running”

I’ve never hear of this humanoidstate thing so ya gotta help me.
I looked at the dev hub for a bit but it doesnt make sense to me.

oh wait my bad i forgot to put an if statement.

You formatted this if statement wrong, it should be

if newstate == Enum.HumanoidStateType.Landed then

That is what is causing your error, in your case your newState was Running, aka Enum.HumanoidStateType.Running and on that you were looking for another state type, so you were essentially doing:
if Enum.HumanoidStateType.Running.Enum.HumanoidStateType.Landed then

1 Like

yeah i just realized that. Thanks for the feedback anyways.

So have you got everything working, or you still need help?

It works! Heres the finished code

local camera = workspace.CurrentCamera

local cameramodule = require(game.ReplicatedStorage.CameraShaker)

local camshake = cameramodule.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	camera.CFrame = camera.CFrame * shakeCFrame
end)

camshake:Start()

local humanoid = script.Parent.Humanoid

humanoid.StateChanged:Connect(function(oldstate, newstate)
	if newstate == Enum.HumanoidStateType.Landed then
		print("Starting Camera Shake")
		camshake:Shake(cameramodule.Presets.Explosion)
		script.Parent["Ground smash sound"]:Play()
	end
	
end)

couldnt have done it without you guys

1 Like

Hey, glad you got it working, just so you know for the future, use three backticks (`) at the beginning and end of your code to format it nicely like this:

if myCode == "nice" then
    return true
else
    print("Please format")
end
1 Like

Ok thanks. I’ll use this further on.

1 Like

Use Humanoid.Jumping instead as Humanoid.StateChanged will fire whenever the humanoid’s state is change to any state.

2 Likes

Everything’s working perfectly thanks to you guys but I have a problem which is completely unrelated here is the link: Character sizer not working