Above is a example of what I kind of want to do.
Hello, I need help making decals change depending on how big of a fraction the block’s health / durability is from the block’s max health.
local Block -- the block
local maxhealth --
local currenthealth --
local DecalsFolder -- has all of the decals (one for each side)
for _, v in pairs(Block:GetChildren()) do
if not v:IsA("Decal") then
local decalsclone = DecalsFolder:GetChildren():Clone()
decalsclone.Parent = Block
end
for _, v2 in pairs(Block:GetChildren())
if v2:IsA("Decal") then
local Fraction= currenthealth / maxhealth * 100
--the pictures depending on how big procentage the current health is from the max
--I believe there would be a better way of doing this table since I don't need 10 different pictures I only need a few.
local PossiblePictures = {
0 = rbxassetid://1
10 = rbxassetid://1
20 = rbxassetid://1
30 = rbxassetid://1
40 = rbxassetid://1
50 = rbxassetid://1
60 = rbxassetid://1
70 = rbxassetid://1
80 = rbxassetid://1
90 = rbxassetid://1
100 = rbxassetid://1
}
local ChosenPicture = table.find(PossiblePictures,Fraction)
v2.Texture = ChosenPicture
end
end
end
I tried this method above , but its not really good