Simple camerashake won´t work

Ok so I´m trying to create a simple camerashake, I have tried a few scripts but all of them use humanoid.CameraOffset which I can´t use since the camera in my game is the view of a Part,
How could I make a somewhat smooth screenshake whithout using the humanoid?
Here´s the code of one of the script I was using:

local character = player.Character
local oldOffset = character.Humanoid.CameraOffset
local shakeIntensity = 3

for i = 0, shakeIntensity * 10 do -- use a value between 0 and 3 (shake intensity), you can also increase the iterations.
	local offset = Vector3.new(math.random(-1,1), math.random(-1,1), math.random(-1,1))
	character.Humanoid.CameraOffset = character.Humanoid.CameraOffset:Lerp(offset, shakeIntensity * 0.25)
	RunService.Heartbeat:Wait() -- defined somewhere else in the script
end
character.Humanoid.CameraOffset = oldOffset

Sleitnick has a module named Shake which shakes the camera by modifying its CFrame.

1 Like

I think it´s perfect, Do you where I can find a link to the module?

This is the source code.

1 Like

Thank you very much! I have been trying to make it myself for hours!

Hey I have a problem, the module requires a module called “trove”, do you know where the model or the code for it is?

Oh ryt mb, I should have lyk about the dependencies. Anyways, here’s trove’s source code. They are all part of a utility package called RbxUtil by sleitnick, so they are other cool modules in there if you are interested. Also trove doesn’t have any dependencies so all should work fine.

Thanks vert much! So saved me somuch time :smiley:

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