Hi,
So Im wondering on how to do this with Color3
values, where I you Interpolate between Points, I already know How to make a Basic Color Interpolation, like for Example a Health bar, where if the Player reaches a Certain point in their Health, The Color would interpolate it to where its in between Green and Red, like so:
local lerpC3 = function(a, b, t) -- Tweening (or Interpolating) a Color3
return Color3.new(a.R * (b.R - a.R) * t, a.G * (b.G - a.G) * t, a.B * (b.B - a.B) * t)
end
local empty = Color3.new(1,0,0) -- when the Bar is about Empty
local full = Color3.new(0,1,0) -- when the Bar is Full
Humanoid.HealthChanged:Connect(function(hp) -- HealthChanged
Frame.BackgroundColor3 = lerpC3(empty, full, hp/Humanoid.MaxHealth) -- Interpolated Color
Frame.Size = UDim2.fromScale(hp/Humanoid.MaxHealth, 1) -- Size
end)
How would I Lerp between More than two Points? Like for Example: If a Player had Full Health
, It would be green, but if they gain an Ability for more Health
above the MaxHealth
, it would transition to a Yellow, and if it were Lower than the MaxHealth
, it would transition to a Red.
Would I need to check if the Value is above a Certain amount? or can I do this with by a method of Lerping?