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

Why is my Anti-Virus erroring?

I have conducted many tests, but the code does not work, I have changed a few things in the script, but it still does not work, the Output says `18:42:02.523 - local VirusNames = {"Script"} local Viruses = 0

local func:6: attempt to call method 'GetChildren' (a nil value) 18:42:02.524 - Stack Begin 18:42:02.525 - Script 'local VirusNames = {"Script"} local Viruses = 0

local func', Line 6 - upvalue ChkScan 18:42:02.526 - Script 'local VirusNames = {"Script"} local Viruses = 0

local func', Line 12 - local ChkScan 18:42:02.527 - Script 'local VirusNames = {"Script"} local Viruses = 0

local func, Line 16 18:42:02.527 - Stack End`, but, I don't know what I'm doing wrong, here is the script;

local VirusNames = {"Script"}
local Viruses = 0

local function ChkScan(Object)
for i,v in pairs(VirusNames) do
for i,v2 in pairs(Object:GetChildren()) do
pcall(function() local ChkName = v2.Name end)
if v2.Name:lower() == v:lower() then
Viruses = Viruses + 1
end
end
ChkScan(v) --Originally at line 11
end
end

ChkScan(game.Workspace)
print(Viruses)

1 answer

GetChildren is a nil value.

That tells us that Object.GetChildren is nil, in other words, Object is a table or string, not a ROBLOX object.

If we look, that is in fact the case. ChkScan(v) requests a scan of v, an element of VirusNames, which is a string.

5 comments

0

How can I fix this?

0

I think I found the problem, for both 'for' loops, I used the same 'i', could that of caused the problem?

0

No, that is not the problem. This shouldn't require nested loops at all. 1st) Compare the name of Object to all elements of VirusNames. Then, do this for all children recursively (loop through Object:GetChildren and call ChkScan on each child)

0

So, like I change 'ChkScan()' to 'ChkScan(game.Workspace)', 'ChkScan(game.ServerScriptService)', ect., or like 'ChkScan(game.Worksace.Model)'?

0

Yes

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