How can I make it so it only starts shaking once the humanoid's health is 80 or under?

I’m not much of a scripter, so my apologizes if this sounds like a dumb easy solution. However, I’m trying to figure out how to make the camera only start shaking once the humanoid starts shaking. I am using the camera shake module made by Leitnick.

wait()
local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char.Humanoid
local humanoidHealth = humanoid.Health

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

humanoid.HealthChanged:Connect(function(Health)
	if humanoidHealth > Health then
		camShake:Shake(CameraShaker.Presets.Bump)
	end
end)
task.wait(3)

local rns = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
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()
humanoid.HealthChanged:Connect(function()
	if humanoid.Health <= 80 then
		camShake:Shake(CameraShaker.Presets.Bump)
		rns.Stepped:Wait() --to not break anything
	end
end)

or without the rns.Stepped:Wait() if needed.

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