p = game.Players.LocalPlayer
c = p.Character
ShakeForHowLong = 100000000 --Shake for 10 seconds.
magnitude = 1 --How much it shakes; can be set to any number or decimal or fraction.

TimePassed = 0 --Ignore
game:GetService("RunService").RenderStepped:connect(function (s)
if TimePassed < ShakeForHowLong then
c.Humanoid.CameraOffset = Vector3.new(magnitude*(math.random()*2 - 1),0,magnitude*(math.random()*2 - 1))
else
c.Humanoid.CameraOffset = Vector3.new(0,0,0)
return
end
TimePassed = TimePassed + s
end)

4 comments

0

Everytime, I play in-game on the ROBLOX client, it doesn't work at all. In studio, it works perfectly fine, what can be the fix for this problem?

0

Hm. Try going into the game.Workspace.Camera I think that is global camera.

0
  1. Use local variables. They get accessed faster in Lua. 2) Provide an example of the code you have tried, and explain what you want it to do. Do not only post code, or only post an explanation. Both are required to make a good question.