String.match matching incorrectly

Hello,

How do I fix this error?
image1

1 Like

. is a string pattern for all characters. Programming in Lua : 20.2

Escape it by doing %.

local str = "4"

if string.match(str, "%.") then
    print("aa")
end

If you’re trying to check if a number is an integer, given that the variable is already casted to a number, you can do:

if x % 1 == 0 then
    print("im an integer")
end
1 Like

since someone replied with an answer, here is a link to show you how string patterns work

% is used to escape special characters

1 Like