Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Using string.find and others like it?

I'm trying to find a string within v's Name and then return that string that was found but I don't know how to as I'm pretty sure string.find does not return a copy of the string.

local name = string.find(v.Name, ele[i])

1 comment

0

can you show a full script please

1 answer

Similar to string.match(), instead of returning the string, it returns the number position of the string, similar of the 2nd parameter to string.sub(). As in if I used.

local s1 = 'Potato'
local s2 = 'tat'
local s3,s4 = string.find(s1,s2) -- string, substring
print(s3 , s4)

Instead of printing, a string, s3 would print 3, because that's where the function found the beginning of the smaller substring. s4 would print 5 because that's where the substring ended. Both s3 and s4 could return nil if the string does not contain a substring.

This discussion is preserved as it was. New answers, comments, and votes are closed.