How can I rotate the player's camera for a camera shake effect?

hi, I’m making a module for a cakera shake effect, the camera will move with CameraOffSet, but how can I rotate it?
this is the progress of the module:

local tweenService = game:GetService("TweenService")

local module = {}

local rnd = Random.new()

module.__index = module

function module.CreateCameraShake(plr,Duration,Intensity,shakes)
	local humanoid = plr.Character.Humanoid
	local self = setmetatable({},module)
	self.duration = Duration or 5
	self.intensity = Intensity or 2
	self.shakes = shakes or 20
	self.shakeduration = Duration/self.shakes
	for i = 1,shakes do
		self.tweenInfo = TweenInfo.new(
			self.shakeduration,
			Enum.EasingStyle.Quad,
			Enum.EasingDirection.InOut,
			0,
			false,
			0
		)
		local tween = tweenService:Create(humanoid,self.tweenInfo,{CameraOffset = Vector3.new(rnd:NextNumber(-self.intensity,self.intensity),rnd:NextNumber(-self.intensity,self.intensity),0)})
		self.intensity -= self.intensity/shakes
		self.shakeduration -= self.shakeduration/shakes/2
		tween:Play()
		tween.Completed:Wait()
	end
end

return module

pretty sure you can just use
camera.CFrame = camera.CFrame*CFrame.Angles(x,y,z)
to rotate the camera

1 Like

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