Crazyman32 Camera Shaker, help needed

Hello! I was wondering how I could possibly use Crazyman32’s camera shaker script. I’ve always used my own custom camera shake, and earlier today I got some feedback on my magic moves that I have been working on, saying that the camera shake is rather choppy and that I should try using EZ Camera Shake ported to Roblox

I’ve looked through all 3 module scripts and find it really confusing and would appreciate some help. Thanks! :slight_smile:

I use this for certain explosions in my game. Basically i just have a bindable event that i can fire with certain parameters that allows me to have a camera shake with certain settings or the built in presets. I think there is more information on crazymans github regarding the modules but hopefully the below example might help you.

This is the code i use:

Shake.Event:Connect(function(Magnitude, Roughness, FadeIn, FadeOut)
	
	local Magnitude = Magnitude or 1
	local Roughness = Roughness or 1
	local FadeIn = FadeIn or 0
	local FadeOut = FadeOut or 1
	
	local Shaker = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
		Camera.CFrame = Camera.CFrame * shakeCFrame
	end)
	
	Shaker:Start()
	
	if type(Magnitude) == "string" then
		Shaker:Shake(CameraShaker.Presets[Magnitude])
	else
		Shaker:ShakeOnce(Magnitude, Roughness, FadeIn, FadeOut)
	end
end)

Edit: See crazyman’s reply for better snippet.

Here’s an bare-bones Baseplate file that shows how you can make use of the Module to shake your player’s Camera every 2 seconds.

CameraShakerExample.rbxl (23.2 KB)

You’ll find the Module itself in ReplicatedStorage, and the LocalScript requiring it in StarterPlayerScripts.

2 Likes

Thanks a lot, this really helped me out.

1 Like

Just FYI you’re introducing a data leak with that code. Every time a new shake event occurs, you’re creating a new shake event and starting it, but it’s never stopped.

Ideally, you should really only need one shaker instance, and you can layer shakes on it if needed. Maybe restructure it a little bit like this:

local Shaker = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	Camera.CFrame = Camera.CFrame * shakeCFrame
end)
Shaker:Start()
Shake.Event:Connect(function(Magnitude, Roughness, FadeIn, FadeOut)
	
	local Magnitude = Magnitude or 1
	local Roughness = Roughness or 1
	local FadeIn = FadeIn or 0
	local FadeOut = FadeOut or 1
	
	if type(Magnitude) == "string" then
		Shaker:Shake(CameraShaker.Presets[Magnitude])
	else
		Shaker:ShakeOnce(Magnitude, Roughness, FadeIn, FadeOut)
	end
end)

All I did there was pull the Shaker initialization outside of the event.

5 Likes

Ohh yeah that was my bad, that was an old code snippet I had from an older file. The newer file had that updated in a similiar fashion to yours, thank you though for the heads up.

1 Like

Thanks soooo much!!! What you said is the answer to my problem T_T!

My script runs 300/s and I was super confused