Interesting string.find discovery.. why does this happen?

So while making some checks for my game, I noticed an interesting discovery with string.find. I’m running string.find and its returning 1 1 instead of nil. This is the code:

string.find(amount, ".")

Is there an alternate way to check if the number contains a decimal? (not using math.floor in this case, trying to learn);

1 Like

If youre trying to find a decimal you can try this

String:match("%d+%.%d+")
1 Like

This worked, thanks! Didn’t know you could use :match that way, I just tried :match(“.”)

1 Like

d+ just checks for a number value, so the one i provided was checking for any numbers followed by a decimal point. :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.