I am trying to make a script that will slowly fade blood onto the players screen. The amount of blood shown will slowly increase the lower their health gets.
I started to attempt this myself, but the way I am doing it seems inefficient. Is there a better way other than manually stating the health values?
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerUI = Player:WaitForChild("PlayerGui")
local BloodEffect = PlayerUI:WaitForChild("ScreenEffects"):WaitForChild("Blood")
Character.Humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth >= 80 and NewHealth <= 99 then
for i = 0,.9,.05 do
BloodEffect.ImageTransparency = i
wait()
end
else if NewHealth >= 60 and NewHealth <= 79 then
for i = 0,.7,.05 do
BloodEffect.ImageTransparency = i
wait()
end
end
end
end)

3 comments
In situations like these I highly suggest using TweenService. Trust me, it is worth learning. I also would get the percentage of health to total health to do this.
Do you need the for loops could you use direct values with UDim.new for BloodEffect.ImageTransparency?
I don't have an answer, but just know, your game may (or may not) get baned by roblox. just sayin...