Is there a way to finding keywords in a script using a script?

I know you’re probably immediately gonna say “Ctrl+Shift+F” but this is for a plugin that helps a developer optimize their game a little.

My idea right now is search through every script in the game and check for 2 conditions, is it a server script? Does the source code contain any of the keywords? If true then send a warn() in the output with the script name and directory.

So far I couldn’t find any forum on this topic.

I imagine that what you would want to do is:

  1. Loop through every single object in the game
  2. Check if it’s the server script (Object:IsA("Script"))
  3. Search its source code for the key words (string.find(Object.Source, "KEYWORD")
  4. If you find a result, do warn(Object) or smth like that

you can use the .Source property of a script to read what is inside of it through code
just do string.find from there with list of keywords

local script = game.ServerScriptService.Script

local keywords = {"robux"}

function checkScript(scr)
 local src = scr.Source
 for i, v in pairs(keywords) do
  if string.find(src, v) then
   warn("i dont like this word: " .. scr.Name)
  end
end

checkScript(script)
1 Like

Didn’t think it was that simple, thanks though!

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