How to get camerashake to work?

Server

wait(1)
local hint = Instance.new("Hint")
hint.Parent = game.Workspace
hint.Text = "THE EARTHQUAKE NOTIFICATION SERVICE HAS ISSUED A SERVRE EARTHQUAKE CLOSE TO YOUR LOCATION.."
script.alert:Play()
wait(1) --20
hint:Destroy()
wait(1) --16
script.earthquakestart:Play()
script.start2:Play()
script.digging:Play()

local getplayers = game.Players:GetChildren()
script.RemoteEvent:FireAllClients()

for i = 1,17.1428571429,1 do
	for i,v in pairs(getplayers) do
		local workplr = game.Workspace:FindFirstChild(tostring(v))
		local humanoid = workplr.Humanoid
		wait(7)
		humanoid.Sit = true
	end
end
script.earthquakestart:Stop()
script.start2:Stop()
script.digging:Stop()

Client

local camera = workspace.CurrentCamera
local CameraShaker = require(workspace.CameraShaker)
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf
end)

camShake:Start()

-- Explosion shake:

script.Parent.RemoteEvent.OnClientEvent:Connect(function()
	while (true) do
		wait(2)
		camShake:Shake(CameraShaker.Presets.Explosion)
	end
end)

First make a remote event in ReplicatedStorage and give it whatever name you want.
Make sure you have CameraShaker in ReplicatedStorage.
Make sure you put the client script in StarterPlayer > StarterPlayerScripts

Server script:

 -- Change RemoteEventName to the name of the remote event you made! (Place your remote event in ReplicatedStorage)
 
 local RemoteEventName = "RemoteEvent"
 
 wait(1)
 
local hint = Instance.new("Hint")
 
 hint.Parent = game.Workspace
 
 hint.Text = "THE EARTHQUAKE NOTIFICATION SERVICE HAS ISSUED A SERVRE EARTHQUAKE CLOSE TO YOUR LOCATION.."
 
 script.alert:Play()
 
 wait(1) --20

 hint:Destroy()
 
 wait(1) --16
 
 script.earthquakestart:Play()
 
 script.start2:Play()
 
 script.digging:Play()
 
 local getplayers = game.Players:GetChildren()
 
 game.ReplicatedStorage:FindFirstChild(RemoteEventName):FireAllClients() -- change
 
 for i = 1,17.1428571429,1 do
 
 for i,v in pairs(getplayers) do
 
 local workplr = game.Workspace:FindFirstChild(tostring(v))
 
 local humanoid = workplr.Humanoid
 
 wait(7)
 
 humanoid.Sit = true
 
 end
 
 end

 script.earthquakestart:Stop()

 script.start2:Stop()
 
 script.digging:Stop()

Client script:

 -- Change RemoteEventName to the name of the remote event you made! (Place your remote event in ReplicatedStorage)
 
 local RemoteEventName = "RemoteEvent"
 
 local camera = workspace.CurrentCamera
 
 local CameraShaker = require(game.ReplicatedStorage.CameraShaker)
 
 local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
 
 camera.CFrame = camera.CFrame * shakeCf

 end)
 
 camShake:Start()

 -- Explosion shake:

 game.ReplicatedStorage:FindFirstChild(RemoteEventName).OnClientEvent:Connect(function()

 while (true) do
 
wait(2)
 
camShake:Shake(CameraShaker.Presets.Explosion)
 
end
 
end)
2 Likes

Do you mind telling me what I did wrong?
It works perfectly and thank you for your help.

1 Like