Camera shake effects player movement

I want to keep player camera control and on top of it add camera shake effects, once hit by a zombie.
For camera shake I use EZ camera shake module:
EZ camera shake module

The camera control looks like this:

The code for this camera control:

local Player = game:GetService("Players").LocalPlayer	
local player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local screenGui = game.StarterGui.ScreenGui

-- here is your template for Vector3 axis (x y z)

local Distance =,25,0) -- Distance from player
local Direction =,-1,0) -- Direction from which camera will be looking at player
local CameraSensitivity = 5 -- change it if you want that camera to lean further (give it a bigger number) 
-- or if want an effect to be more subtle decrease the number. (if you set it as a negative, camera will lean in the opposite direction)

function getMouseScreenPositionCentered() 
		mouse.X - screenGui.AbsoluteSize.X/2,
		mouse.Y - screenGui.AbsoluteSize.Y/2)

function pixelToFraction(pixelV2)
	--Turns a coordinate in pixels into a coordinate in some fraction of the size of the screen
	return pixelV2 / screenGui.AbsoluteSize

function onRenderStep() 	
	if player.Character then
		local rootPart = player.Character.HumanoidRootPart
		local playerposition = player.Character.HumanoidRootPart.Position +,0,3) -- sometimes camera will be offset to your character, 
		local cameraoffset = Distance + playerposition

		local mouseScreenPos = pixelToFraction( getMouseScreenPositionCentered() )
		local Axis =,0,mouseScreenPos.X)

		local cameraPos = cameraoffset + Axis * CameraSensitivity 
		camera.CFrame =, cameraPos + Direction)

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

The bug (in the presented video only the key “S” is pressed):

The camera shake is activated by this remote event local script:

local CameraShaker = require(game.ReplicatedStorage.CameraShaker)

local Player = game:GetService("Players").LocalPlayer	
local camera = workspace.CurrentCamera

local camShake =, function(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf


	if Type == "Explosion" then


Thanks in advance!

1 Like

do you have the UserInput code? where is it?

1 Like

There is no other UserInput script only the camera controller which is inside StarterPlayerScripts

could you send the CameraController script?

The solution after all was disabling camera’s relativity to the controls