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

Why is my AV erroring?

Asked by 10 years ago

I tried doing some changes, it only works once but then stops, the error says 13:41:55.070 - Workspace.TDC'sAV\:19: attempt to index local 'Object' (a nil value) 13:41:55.072 - Stack Begin 13:41:55.074 - Script 'Workspace.TDC'sAV\', Line 19 - upvalue Scan 13:41:55.075 - Script 'Workspace.TDC'sAV\', Line 26 - local Scan 13:41:55.076 - Script 'Workspace.TDC'sAV\', Line 31 13:41:55.078 - Stack End But, I don't understand what I'm doing wrong, I've checked lines 19, 26, and 31 but I can't figure out the problem, here is the script;

wait(0)

--local AntiVirus=plugin:CreateToolbar("TheeDeathCastre's Anti-Virus")
--local AVButton=AntiVirus:CreateButton("","Start Scan","http://www.roblox.com/asset/?id=163720453")

local Viruses = {"Infected"}

local function AntiVirus(Object)
for i,v in pairs(Viruses)do
if Object.Name:lower():find(v:lower())then
Object:Destroy()
end
wait(.1)
end
end

local function Scan(Object)
for i,virus in pairs(Viruses)do
for i , scanning in pairs(Object:GetChildren())do
if scanning.Name:lower():find(virus:lower())then
scanning:Destroy()
end
wait(.1)
end
wait(.1)
Scan(v)
end
end

--function StartScan()
Scan(game:GetService("Workspace"))
Scan(game:GetService("Lighting"))
Scan(game:GetService("ServerScriptService"))
Scan(game:GetService("Players"))
Scan(game:GetService("ReplicatedFirst"))
Scan(game:GetService("ReplicatedStorage"))
Scan(game:GetService("Teams"))
Scan(game:GetService("StarterGui"))
Scan(game:GetService("StarterPack"))
Scan(game:GetService("Debris"))
Scan(game:GetService("SoundService"))
--end

--AVButton.Click:connect(StartScan)

game.DescendantAdded:connect(AntiVirus)

1 answer

Log in to vote
0
Answered by 10 years ago

You never indicated what v is on line 26. So by saying Scan(v), you're basically saying Scan(nil) because you never defined what v is. When the function is called with v as the argument, it's trying to the get the children of nil, which isn't possible. I think you're supposed to replace v with scanning. Hope this helped!

EDIT: Fixed Code

wait()

--local AntiVirus=plugin:CreateToolbar("TheeDeathCastre's Anti-Virus")
--local AVButton=AntiVirus:CreateButton("","Start Scan","http://www.roblox.com/asset/?id=163720453")

local Viruses = {"Infected"}

local function AntiVirus(Object)
    for _,v in pairs(Viruses)do
        if pcall(function() local Test = Object.Name end) then --I added this here because sometimes it would say "an error occured" when it tried to get the Object's name
            if Object.Name:lower():find(v:lower())then
                Object:Destroy()
            end
        end
    end
end

local function Scan(Object)
    for _,virus in pairs(Viruses)do
        for _,scanning in pairs(Object:GetChildren())do
            if scanning.Name:lower():find(virus:lower())then
                scanning:Destroy()
            end
            Scan(scanning) --The calling of the function "Scan" was in the wrong place
        end
    end
end

--function StartScan()
Scan(game:GetService("Workspace"))
Scan(game:GetService("Lighting"))
Scan(game:GetService("ServerScriptService"))
Scan(game:GetService("Players"))
Scan(game:GetService("ReplicatedFirst"))
Scan(game:GetService("ReplicatedStorage"))
Scan(game:GetService("Teams"))
Scan(game:GetService("StarterGui"))
Scan(game:GetService("StarterPack"))
Scan(game:GetService("Debris"))
Scan(game:GetService("SoundService"))
--end

--AVButton.Click:connect(StartScan)

game.DescendantAdded:connect(AntiVirus)
0
Alright, thanks, I'll do that. :) TheeDeathCaster 2368 — 10y
0
It didn't work. D: Its saying the same error. :( TheeDeathCaster 2368 — 10y
0
I edited my answer and posted the fixed code TurboFusion 1821 — 10y
Ad

Answer this question