So here's my current code:
function replaceString(s, f, r) s = tostring(s) local str, e = s:find(f) return s:sub(1, str-1)..r..s:sub(e+1, #s) end function stringToTable(s) local t = {} local currentString = "" for i = 1,#s do if string.sub(s,i,i) == "\n" then table.insert(t,currentString) currentString = "" else currentString = currentString..string.sub(s,i,i) end end return t end local linebreakTable = stringToTable(builtscript) local rebuild = '' for i,v in pairs(linebreakTable) do if string.find(v, 'PlayerGui') then v = replaceString(v, ':WaitForChild("PlayerGui")', '') end rebuild = rebuild .. string.format(tostring(v) .. '\n') end builtscript = rebuild
It should remove the :WaitForChild inside the lines that include PlayerGui right? Well ROBLOX doesn't think so.
Error: 140: attempt to perform arithmetic on local 'str' (a nil value)
I'm going to see if putting this script inside a Server-Script will fix anything.