How to make a camera shake that adapts to these situations?

I want to make a camera shake module for my project.
In this project, most of the time, the player will not have his own character. Still, I want to do camera shake, independently of whoever is playing (game is turn based). So this brings me to a big problem…

How do I handle the shakes while the Camera state is as default?
Most of the answers I have seen to this question rely mainly on the CameraOffset property of the Humanoid. My problem here is how can I make this for characters which are not the player’s? How would I handle this with an object that does not have a Humanoid?

All help is appreciated.

1 Like

You could just use EZ Camera Shaker, it is a powerful yet simple module. Just note that all the functions of the module are not entirely listed on the GitHub page and you should review the module’s code.

LocalScript(In StarterGui):

local function shakeCamera(length)
	
	local startTime = tick()
	
	while true do
		
		if tick() - startTime >= length then break end
		
		local x = math.random(-100, 100) / 1000
		local y = math.random(-100, 100) / 1000
		local z = math.random(-100, 100) / 1000
		
		game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(x, y, z)
		workspace.CurrentCamera.CFrame *= CFrame.Angles(x / 100, y / 100, z / 100)
		
		wait()
	end
	
	game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
end


game.ReplicatedStorage.Shakecam.OnClientEvent:Connect(function(t)
	shakeCamera(t)
end)

Script by @Sub2HTR

You must add RemoteEvent ‘Shakecam’.
And Fire if you want to shake. [Server]

	game.ReplicatedStorage.Shakecam:FireAllClients(10) -- time
1 Like

I will look into it! However, I wanted to use my own module in order to adapt it easier for current and upcoming projects!

Man, Im dumb. I didnt realise I could just change the CFrame. Thanks!