Move camera while having camera shake?

I want to move the camera forward while having a camera shake effect but no matter what I try I cant get the desired outcome. If I use TweenService to move the camera it ignores the shake, and if I try using my own math, it ends up failing.

I also searched it up but none of the answers work.

local RUNSERVICE = game:GetService("RunService")

local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable

local maxXoffset = 0.5
local maxYoffset = 0.5

local cXoffset = 0
local cYoffset = 0

local rng = Random.new()

local shakeMoveCon
shakeMoveCon = RUNSERVICE.RenderStepped:Connect(function(dt)
	local rXoffset = rng:NextNumber(-maxXoffset, maxXoffset)
	local rYoffset = rng:NextNumber(-maxYoffset, maxYoffset)
	cam.CFrame *= CFrame.new(rXoffset-cXoffset, rYoffset-cYoffset, -dt*10)
	cXoffset = rXoffset
	cYoffset = rYoffset
end)

task.wait(5)
shakeMoveCon:Disconnect()
cam.CFrame *= CFrame.new(-cXoffset, -cYoffset, 0)

this script would shake the camera on the X and Y axis while moving it forward for 5 seconds

yes that works great thank you!

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