hi again!! having.. more trouble with a script.

Me and a friend are working on a roleplay game. We have a GUI that allows you to input a decal ID and use that for your character:



function setMorph()
	local character = game.Players.LocalPlayer.Character
	local inputText = script.Parent.Parent.Input.Text
	local resultText = "http://www.roblox.com/asset/?id=" .. inputText
	
	character.Torso.Front.Texture = resultText
	character.Torso.Back.Texture = resultText
end

script.Parent.MouseButton1Click:Connect(setMorph)

It works- the trouble is that usually you need to replace the last digit of the ID over and over and over for up to 20 times for the decal to actually work, since the image ID itself is different.

I was hoping that I could make a script that, once someone inputs a decal ID, it will automatically scroll through the last digit (and possibly the 2nd-to-last if it needs to and so forth) until it finds an image to use thats not.. blank.

I'm **not ** asking that anyone make a script for me, since I know that's not allowed, but does anyone know how I would even begin to script something like this? I know that Starcross (a roleplay game) does this, but I have no clue how to even begin.. if anyone has a general idea of what I should do, please let me know!!