So I've this tool that is supposed to, on use, delete anything nearby that are inside a certain folder (EventBuildings).
Here's the script (serverscript inside the tool itself)
local eventbuildings = game.Workspace.EventBuildings
local function createselectionbox(adornee)
--blah blah
end
script.Parent.Activated:Connect(function()
if script.Parent.InUse.Value == false then
script.Parent.InUse.Value = true
wait(0.15)
script.Parent.Handle.UseNoise:Play()
local handle = script.Parent.Handle
local num = 50
local region = Region3.new(Vector3.new(handle.Position.X - num, handle.Position.Y - num, handle.Position.Z - num), Vector3.new(handle.Position.X + num, handle.Position.Y + num, handle.Position.Z + num))
local parts = game.Workspace:FindPartsInRegion3(region, nil, math.huge)
for a, b in pairs(parts) do
if b:IsA("BasePart") or b:IsA("MeshPart") then
if b.Parent.ClassName == ("Model") and b.Parent.Parent == eventbuildings then
createselectionbox(b.Parent)
elseif b.Parent == eventbuildings then
createselectionbox(b)
end
end
end
wait(1)
for a, b in pairs(parts) do
if b:IsA("BasePart") or b:IsA("MeshPart") then
if b.Parent:IsA("Model") and b.Parent.Parent == eventbuildings then
for c, d in pairs(b.Parent:GetChildren()) do
table.remove(parts, c)
end
b.Parent:Destroy()
elseif b.Parent == eventbuildings then
b:Destroy()
end
end
end
wait(script.Parent.Handle.UseNoise.TimeLength - 0.15)
script.Parent:Destroy()
end
end)
Whenever I use the tool I get this error.
16:24:19.949 - Workspace.Old Pocket Watch.Script:28: attempt to index nil with 'IsA'
I tried fixing it by removing those parts from the table which didn't work. I am now completely stumped.

4 comments
Have you tried printing a few debugs? like after line 26 print(b) and print(b.Parent) .
Doing that just makes the script get stumped on the print statements. I now get 'Workspace.Old Pocket Watch.Script:27: attempt to index nil with 'Name''
Check if it's parent is not nil.
Yeah, that did it. Thanks