Shaking When Closer to an Entity

I need my screen to shake more when closer to an entity and less when farther.
Unfortunately… nothings worked.
I wanted to achieve this with EZ Camera Shaker.
The issue is I’m kinda confused so I don’t know how to figure this out.
I tried the dev forum but couldn’t find what I’m looking for sadly.
This is my code. It’s very bad as I’ve never used EZ Camera Shaker before.

game.Workspace:WaitForChild("A15")
local player = game.Players.LocalPlayer
local magnitude = (game.Players.LocalPlayer.HumanoidRootPart.Position - game.Workspace.A15.MainPart.Position).Magnitude


local a15 = workspace.A15

local camera = workspace.Camera

local CameraShaker = require(game.ReplicatedStorage.CameraShaker)

local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	camera.CFrame = camera.CFrame * shakeCFrame/magnitude
end)

camShake:Start()

local touched = false

function nearPart()
	camShake:ShakeOnce(CameraShaker.Presets.Bump)
end

if (game.Players.LocalPlayer.HumanoidRootPart.Position - game.Workspace.A15.MainPart.Position) <= 500 then
	nearPart:Connect()
end
1 Like
(game.Players.LocalPlayer.HumanoidRootPart.Position - game.Workspace.A15.MainPart.Position) <= 500

Should be:

(game.Players.LocalPlayer.HumanoidRootPart.Position - game.Workspace.A15.MainPart.Position).Magnitude <= 500

you do realise that a player object isn’t the same as the character…

you should be doing

(game.Players.LocalPlayer.Character.HumanoidRootPart.Position - game.Workspace.A15.MainPart.Position).Magnitude <= 500