How can I get a specific string through a plugin in a script?

I’ve searched the forum for information on this, but haven’t found an answer…
I tried to use a loop with character traversal with Source something like this:

local function GetStrings(source)
	local i = 0
	local stringLenght = string.len(source)

	local thisStringLenght = 0	
	local thisString = ''
	while i ~= stringLenght do
		i += 1
		thisStringLenght += 1
		if string.sub(source, i, i + string.len("\n")) == "\n" then
			print(thisString)
			thisString = ""
		else
			thisString = thisString..string.sub(source, i, i)
		end
	end
end

Does anyone know what’s wrong here? Is there any way/method to make it quicker and shorter?
P.S. I’ve been looking for a solution for about 1.5 hours now…

The string library seems to be what you’re looking for: string | Roblox Creator Documentation. Specifically the string.find function.

You could use this as well:

local function GetStrings(source)
    local strings = string.split(source, "\n")
    for i,thisString in strings do
	    print(thisString)
    end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.