Problem with string.find not finding the correct number

I’m having a weird issue where string.find is finding the number 5 every time, even when it’s not present in the string. I’m trying to isolate the numbers from strings using a string pattern, and this happens in a little test loop I wrote.

Here’s the code:

for i = 1, 15 do
	local SlotName = "Slot"..i
	print(SlotName)
	local Number = string.find(SlotName, "%d")
	print(Number)
end

Here’s the output:
image
As you can see, the SlotName prints as expected. The Number does not.

Any help is appreciated!

The string pattern you’re using will search for any digit.

With that said, string.find returns the starting index/position in the string of where the match was found. In all cases, the starting index is 5.

Whoah, I really misunderstood what string.find is used for. Do you know how I’d go about returning the actual digits that are found in the string?