I want to change a parts color but depending on the parts “health”
I have a part with a maxhealth and health value in it. I want to change the RGB color in a script depending on the maxhealth, health, and number 255. Only the problem is I am terrible at math and don’t know how to make this work/
the only thing I need is math right now I have this
while wait(.2) do
if HoldingMB1 == true then
local t = Mouse.Target
if t then
if t:HasTag("Mineable") then
local Damage = 1-t:FindFirstChild("Toughness").Value
local Health = t:FindFirstChild("Health")
game.ReplicatedStorage.MineHandler:FireServer({Action = "Destroy",Part = t,Health = Health,Damage = Damage})
Health.Value-=Damage
local MaxHealth = Health:FindFirstChild("MaxHealth").Value
local DefaultColor = t.DefaultColor.Value
--t.Color = Color3.fromRGB(DefaultColor.R-255/(Health.Value*255),DefaultColor.G,DefaultColor.B)
if Health.Value<=0 then
t.Transparency = 1
end
end
end
end
end
commented out conde is the part I tried trying to create bu thte math was worng it turned black instantly