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)
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.