The shaking keeps the camera on just one position

What do I want to achieve? A shaking effect with angles and position involved.

What is the issue? The shaking only shakes on angles, the position is revealed to not be changed. Whenever I move my character, it reveals that the camera position NEVER changes. It stays in ONE position.

What solutions have you tried so far? I have tried to comment out the change of the angles, however I want it to change the angles too.

Code having the issue:

while task.wait() do

	if workspace:FindFirstChild("CameraShaker") then
		
		local intensity = workspace.CameraShaker.Intensity.Value
		local range = 55


		local cam = workspace.Camera
		if workspace.CameraShaker.OnOrOff.Value == true then
			game:GetService('TweenService'):Create(game.Workspace.Camera,TweenInfo.new(0, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0),{CFrame = cam.CFrame * CFrame.Angles(math.rad(math.random(-intensity/2, intensity/2)),math.rad(math.random(-intensity/2, intensity/2)),math.rad(math.random(-intensity/2, intensity/2)))}):Play()
			game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(math.random(-intensity, intensity), math.random(-intensity, intensity), math.random(-intensity, intensity))
		else
			game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0,0,0)
		end
		
	else
		
		print('where is it')
		
	end

end

Video holding the example:
robloxapp-20250119-1550117.wmv (427.2 KB)
(MUST DOWNLOAD IN ORDER TO WATCH. I DO NOT HAVE CONTROL OF IT.)

(Bump) Has not been solved. Someone help me

Really simple mistake but, You are using a tween on the camera. Sadly I have had this exact same struggle in the past and I know the exact fix. assuming you are trying to make screen shake that is smooth rather than teleporting around.

Instead of using tween you need to use math.noise() wich will give a noise do that however many times for each axis you want to be effected by the screen shake. then add the random positions to the camera and now you have a smooth shaking camera.

Hope this helps :smiley:

i think i have it set up incorrectly

while task.wait() do

	if workspace:FindFirstChild("CameraShaker") then

		local intensity = workspace.CameraShaker.Intensity.Value
		local range = 55


		local cam = workspace.Camera
		if workspace.CameraShaker.OnOrOff.Value == true then
			workspace.CurrentCamera.CFrame = CFrame.new() * CFrame.Angles(math.noise(intensity, intensity, intensity), math.noise(intensity, intensity, intensity), math.noise(intensity, intensity, intensity))
			game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(math.random(-intensity, intensity), math.random(-intensity, intensity), math.random(-intensity, intensity))
		else
			game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0,0,0)
		end

	else

		print('where is it')

	end

end

im not good at making shaking

Ok so your problem here is due to the way noise works feeding it the same value will give the same result. what you need to do is also add something like tick() inside the noise value and then multiply the noise value by intensity so it would look a little like this

local Frequency = 1
local Intensity = 5 

workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(
	(math.noise(tick() / Frequency) % 1 ) * Intensity,
	(math.noise(tick() / Frequency) % 1 ) * Intensity,
	(math.noise(tick() / Frequency) % 1 ) * Intensity
)

I added tick as it is a timer since a point in the past that doesn’t matter all we care is it go’s up over time,

I also added a frequency to it because this currently goes really slow (I THINK) increase it to have faster waves

But that will give the same vectors for each one so they will always align.
If that is an undesired effect add a random offset to them all

local R = Random.new()

local offset1 = R:NextNumber(0,1)
local offset2 = R:NextNumber(0,1)
local offset3 = R:NextNumber(0,1)

workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(
	(math.noise((tick() + offset1) / Frequency) % 1 ) * Intensity,
	(math.noise((tick() + offset2) / Frequency) % 1 ) * Intensity,
	(math.noise((tick() + offset3) / Frequency) % 1 ) * Intensity,
)

This does the same as the last example but it adds a 0 - 1 offset to it. The reason its only 0 - 1 because when the noise map hits 1 it returns to where it started at 0.

I used a random object (Random.new()) to get the :NextNumber() function and that will return any number between two decimals. so its just math.random() that supports decimal placements.

Hope this helps :smiley:

The issue still occurs/persists. Is there another solution?

I tried:

while task.wait() do

	if workspace:FindFirstChild("CameraShaker") then
		
		local Frequency = 1
		local Intensity = workspace:FindFirstChild("CameraShaker").Intensity.Value
		local R = Random.new()

		local offset1 = R:NextNumber(0,1)
		local offset2 = R:NextNumber(0,1)
		local offset3 = R:NextNumber(0,1)

		workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(
			(math.noise((tick() + offset1) / Frequency) % 1 ) * Intensity,
			(math.noise((tick() + offset2) / Frequency) % 1 ) * Intensity,
			(math.noise((tick() + offset3) / Frequency) % 1 ) * Intensity
		)

	else

		print('where is it')

	end

end

I would suggest turning the frequency to be a decimal that isnt a whole number (eg 1.5)

I would also suggest you move the random offset stuff out of the loop as that will re calculate the offset every frame turning it into a frame random offset.