I want to use the Ez shake module( EZ Camera Shake ported to Roblox ) to create screen shaking during explosions. I have connected this module. But the problem is that I have a local script for smoothly rotating the camera. It overrides the shaking animation and does not allow it to work normally. By turning off the smooth rotation script, the shaking works as it should. But once you turn this script back on, there is no shaking anymore.
How can this be fixed? disabling the script of smooth rotation at the time of the explosion is not very good, since the camera position is still set there in relation to the character, and the shutdown will be very noticeable
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local Time = 5
local Starttime = tick()
repeat
wait()
local endtime = tick()
local xoffset = math.random(-100,100) / 500 --the lower the more shaky the higher the less shaky
local yoffset = math.random(-100,100) / 500 --the lower the more shaky the higher the less shaky
local zoffset = math.random(-100,100) / 500 --the lower the more shaky the higher the less shaky
hum.CameraOffset = Vector3.new(xoffset,yoffset,zoffset)
hum.CameraOffset = Vector3.new(xoffset,yoffset,zoffset)
until endtime - Starttime >= Time
hum.CameraOffset = Vector3.new(0,0,0)
well is “shakeEvent” even firing? add a print statement in on OnClientEvent, and the if statement may be messing with it, try removing the if and see if it works
local CameraShaker = require(game.ReplicatedStorage.Modules.CameraShaker)
local camera = game.Workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local centerPart = game.Workspace.SixEightTwo.HumanoidRootPart
local distanceToPart = 50
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
camera.CFrame = camera.CFrame * shakeCFrame
end)
camShake:Start()
-- Explosion shake:
game.ReplicatedStorage.Remotes.Shake.OnClientEvent:Connect(function()
if (camera.CFrame.Position - centerPart.CFrame.Position).Magnitude < distanceToPart then
camShake:Shake(CameraShaker.Presets.Explosion)
end
end)