Is this function for making the players screen change on damage efficient?

Heres an image of the code:

No, you should be using .HealthChanged for this. Paste your code here and I can fix it.

function VignetteDisplay()
	RunService.RenderStepped:Connect(function()
		
		for i, v in ipairs(Display:GetDescendants()) do
			if v:IsA("ImageLabel") then
				v.ImageTransparency = Humanoid.Health / 100
			end
		end
		Lighting.ColorCorrection.Saturation = Humanoid.Health / 100 - 1
	end)
end

Change it to this:

function VignetteDisplay()
	Humanoid.HealthChanged:Connect(function(health)
		for i, descendant in ipairs(Display:GetDescendants()) do
			if descendant:IsA("ImageLabel") then
				descendant.ImageTransparency = health / 100
			end
		end
		
		Lighting.ColorCorrection.Saturation = health / 100 - 1
	end)
end
3 Likes