Why I cant find point in string

local a = 15325.1555
print(string.find(tostring(a),“.”))

Output
1 1

Why ?
I’m going to convert a number to its group id now, but I need to know if that number is its groupid.

1 Like

The period character is a magic character in string pattern, it just matches anything. Lucky for you, string.find has an optional last parameter that determines if string.find should use string patterns for the second argument. The argument before it is where to start finding, so you’ll need to provide that first.

This leaves you with string.find(tostring(a), ".", 1, true), or if you want, you can escape the period with a percent sign. Which would leave you with string.find(tostring(a), "%.")

4 Likes