Changing Decals on how big of a fraction / procent

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

change whatever this is

to this

for BlockHealth, Texture in ipairs(PossiblePictures) do
	if Fraction >= BlockHealth then
		v2.Texture = Texture
	else
		break
	end
end

Is there a better way to make it so when the currenthealth is at a fraction maybe 10% , but when its anywhere above or below its something else, also the table I made is pretty wierd or is it not?

I had the same problem from my previous mining games.

What I did to solve this was to store the breaking stage textures in an array in order from the beginning to last.

Then loop through the texture array and check if the break progress is greater than the loop index divided by the length of the texture arrays.

In this way, you won’t have to list all percentages and you can even have more than 10 breaking stage textures.

sample code because my english is confusing:

for i = 1, #textures do
    if progress >= (i / #textures) then
       print("stage: " .. i)
    end
end

This may not be the best solution but I’ll help just in case.