Is string.find returning the wrong values, or am I using it wrong?

Hi, in this example I’d expect string.find to return 4 as the character “.” appears in the fourth position. Am I using this wrong or is this a bug?

image
Thanks

You have to give the argument init

string.find ( string s, string pattern, number init = 1, bool plain = false )

. is a string pattern for “any character”. By default, string.find does this. You can read more about string patterns here: Strings | Documentation - Roblox Creator Hub

Anyway, to fix your problem, string.find has an argument you can pass true to. Doing so will do a plaintext match.

string.find("100.2", ".", 1, true)

2 Likes


From the dev hub