I’m currently working on a module to make uses of RichText easier. Since a few minutes, I’m struggling trying to find a fix for the issue I’m currently having. For some reasons, string:find() doesn’t seem to find an element in a string. Here’s what I mean:
My string is “This is a test, !COLOR-END!”.
My code is string:find("!COLOR-END!")
It is clear that “!COLOR-END!” is in the string, however my code returns nil and I don’t understand why.
do string.find instead of string:find | string:find would be accessing a member function of an object while string.find would be accessing a function in the string class.
local stringssss = “This is a test, !COLOR-END!”
print(string.find ( stringssss, “!COLOR-END!”, 1, true)) | Setting the last parameter to string.find to true makes the function not detect magic characters which the hyphen (-) is reserved as | You can read more about the string.find function in the API reference here string | Roblox Creator Documentation
PS: magic characters can be ignored completely, by setting the fourth string.find parameter to true(for intended behavior the third parameter should be set to 1):