I know that you can already get the Texture ID from a Decal ID by subtracting the Decal ID by 1, however, sometimes, the Texture ID isn't necessarily one less than the Decal ID. Sometimes, there is a difference of two or even three. I am trying to create a way to detect what the difference would be.
Here's my scrap code. For the sake of testing, I purposely used a Decal ID whose Texture ID was not 1 less than it.
local difference = 1
local decalID = --[[User Given ID via GUI Input]]--
while "http://www.roblox.com/asset/?id="..(decalID - difference) == nil do
difference = difference + 1
end
print(difference)
script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id="..(decalID - difference)
The problem is in this line:
while "http://www.roblox.com/asset/?id="..(decalID - difference) == nil do
I'm checking to see if it's nil, but it still gives me an error and stops the script. I know it is wrong and technically it can't be nil since it is an existing value, but I don't know any other method of checking to see if it is a valid Texture.
I have also tried it like this:
while script.Parent.ImageLabel.Image == nil do
difference = difference + 1
script.Parent.ImageLabel.Image = "http://www.roblox.com/asset/?id="..(decalID - difference)
end
...and that also does not work.
Any ideas on how to do this?

2 comments
No, actually, you can concact a number with a string. Lua automatically tostrings it for you. Also, thank you for that link.
Does it? Oh, thank you. I never knew that.