Screen shake script not working

Basically im making so that if you touch a part an earthquake happens, but nothing happens when i touch the part.

local part = game.Workspace.Wall2Trigger
part.Touched:Connect(function(hit)
	local camera = workspace.CurrentCamera
	local CameraShaker = require(game.ReplicatedStorage.CameraShaker)
	local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
		camera.CFrame = camera.CFrame * shakeCFrame
	end)
	camShake:Start()
	camShake:StartShake(20,19,18,20)
	wait(39)
	camShake:Stop()
end)

Avoid directly accessing objects from workspace as they might not be immediately available on the client. Instead, use WaitForChild to ensure the object is loaded before accessing it. For example:

local part = game.Workspace:WaitForChild("Wall2Trigger")

Sadly it doesn’t work, i dont think its the problem tho

I have tested your script and it is working fine for me, Is script a server or local?

Local script on StarterPlayerScripts

Can you check if there are any errors in the output?


this is the only thing

The CameraShaker Module does not exist, Are you sure it is really there?

immagine

Got it, so you gave the script the wrong path that’s why it didn’t work.

local part = game.Workspace:WaitForChild("Wall2Trigger")
part.Touched:Connect(function(hit)
	local camera = workspace.CurrentCamera
	local CameraShaker = require(game.ReplicatedStorage.Modules:WaitForChild("CameraShaker"))
	local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
		camera.CFrame = camera.CFrame * shakeCFrame
	end)
	camShake:Start()
	camShake:StartShake(20,19,18,20)
	wait(39)
	camShake:Stop()
end)

This should work without a problem.

1 Like

ty so much, im so stupid lol. Next time ill be more careful

1 Like

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