No problem. Whenever you need help, just ask!
I like this one:
local function Shake_Cam_Event_sub()
local x = math.random(-100,100)/100
local y = math.random(-100,100)/100
local z = math.random(-100,100)/100
local step_int = 1
for counter_a = 10, 0, -1 do
step_int = step_int * -1
local shift_int = counter_a/10 * step_int
local xx = x*shift_int
local yy = y*shift_int
local zz = z*shift_int
Humanoid.CameraOffset = Vector3.new(xx,yy,zz)
wait(0.01)
end
end
15 Likes
May i know why we need math.random(-100,100)/100
That is because math.random can’t do decimal places, so we go up to -100, 100 and then scale back down to -1, 1 but this time with 2 decimal places.
(alternative could be Random.new, but that’s your choice.)
This code may or may not have been written by an ai…
local function shakeCamera(camera, duration, intensity, frequency)
local originalPosition = camera.CFrame.Position
local startTime = tick()
local function update()
local currentTime = tick()
local elapsed = currentTime - startTime
if elapsed < duration then
local offsetX = math.sin(elapsed * frequency) * intensity
local offsetY = math.cos(elapsed * frequency) * intensity
local newPosition = Vector3.new(
originalPosition.X + offsetX,
originalPosition.Y + offsetY,
originalPosition.Z
)
camera.CFrame = CFrame.new(newPosition, originalPosition)
else
camera.CFrame = CFrame.new(originalPosition)
end
end
-- Connect the update function to a RenderStepped event
local connection
connection = game:GetService("RunService").RenderStepped:Connect(function()
update()
-- Disconnect the event when the duration is over
if tick() - startTime >= duration then
connection:Disconnect()
end
end)
end