Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my Anti-Virus erroring?

Asked by 9 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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.

0
How can I fix this? TheeDeathCaster 2368 — 9y
0
I think I found the problem, for both 'for' loops, I used the same 'i', could that of caused the problem? TheeDeathCaster 2368 — 9y
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) BlueTaslem 18071 — 9y
0
So, like I change 'ChkScan()' to 'ChkScan(game.Workspace)', 'ChkScan(game.ServerScriptService)', ect., or like 'ChkScan(game.Worksace.Model)'? TheeDeathCaster 2368 — 9y
0
Yes BlueTaslem 18071 — 9y
Ad

Answer this question