Module Script Help

I want to check for Viruses and see if they are a script

It says I am lacking permission look:
What it looks like:
image

What I get:
image

I have went on youtube.com

I am trying to make a Anti-Virus and I am checking if the object is a script or module script but when I do that it says I am lacking permission on my script why?

local module = {}

local virusDefinitions = {
	"vaccine";
	"virus";
	"antivaccination";
	"antivaccine";
	"antivxccination";
	"antivxccine";
	"infection";
}

function module:AntiVirus(call)
	if call:lower() == "destroyvirus" then
		for _, object in pairs(game:GetDescendants()) do
			for _, virusName in pairs(virusDefinitions) do
				if object:IsA("Script") or object:IsA("ModuleScript") then
					if object.Name:lower() == virusName then
						object:Destroy()
						warn("Found a virus, virus was destroyed!")
					else
						return "No Virus Found"
					end
				end
			end
		end
	elseif call:lower() == "viruschecker" then
		for _, object in pairs(game:GetDescendants()) do
			for _, virusName in pairs(virusDefinitions) do
				if object:IsA("Script") or object:IsA("ModuleScript") then -- error happens here
					if object.Name:lower() == virusName then
						warn(object.Name .. ": Is a Virus In :" .. object.Parent)
					else
						return "No Virus Found"
					end
				end
			end
		end
	elseif call:lower() == "null" then
		--// code Ignore this one just becuase I havent came up with any other ones for virus checking
	end
end

return module

The error happens on line 30 :frowning:

There are some services that you can’t reach, such as CoreGui or CorePackages. You may use only specified services that you can achieve.

1 Like

How would I check if they are not that?

@ProBaturay :grinning_face_with_smiling_eyes: read message abovee

You can actually prepare a table for the services you want to get and check if they were found.

local listOfServices = {
    game:GetService("Workspace"),
    game:GetService("ReplicatedStorage")
}

for i, object in pairs(game:GetDescendants()) do
    if table.find(listOfServices, object) then
        print(object)
    end
end

There is nothing to do with the Name property since it prevents the script from running. You will get the same error. This is the better way to get the services.

And also I suggest you use string.find because every virus scripts’ name won’t be the same as the names passed to the table.

local list = {
    "Virus",
    "Infect",
    "Antivaccine",
}

script.Parent.FocusLost:Connect(function()
    for i, object in ipairs(list) do
	    if string.find(script.Parent.Text, list[i]) then
		    print("Virus is found!")
	    end
    end
end)

This is just a text box, and when you type virus in it, it will print.

1 Like