Custom Damage Blur

I wanted to make it so that when the player takes damage a blur appears, but right now it gives blur anytime the health changes instead of once when they take damage, so as they heal it keeps blurring, and also it does not play each time you get hit and you can see clearly multiple times without blur appearing

local player = game.Players.LocalPlayer

local tweenService = game:GetService("TweenService")
local lighting = game:GetService("Lighting")
local blurTween = tweenService:Create(lighting:WaitForChild("Blur"), TweenInfo.new(1, Enum.EasingStyle.Sine), {Size = 0})

local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
--local health = humanoid.Health

local blur = game.Lighting.Blur

humanoid.HealthChanged:Connect(function()
	if character.Humanoid.Health < 100 then
		blur.Size = 15
		blurTween:Play()
	end
end)
1 Like
local oldHealth = 100

humanoid.HealthChanged:Connect(function(newHealth)
 local difference = newHealth - oldHealth
 if difference < 0 then
  -- player took damage
 end
end)
1 Like

Store the old health value, and once the health changes compare the new value to the old one, and if the health has gone down then show the blur

1 Like