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")
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)