Maybe putting this code in a script inside the HammerBasement model would work.
local basement = script.Parent
local planksDestroyed = 0
local conn
conn = basement.ChildRemoved:Connect(function(child)
If child.Name:match("Plank") then
planksDestroyed += 1
if planksDestroyed == 2 then
basement.MainDoor:Destroy()
basement.BasementExit:Destroy()
conn:Disconnect()
end
end
end)
game.Workspace.HammerBasement.ChildRemoved:Connect(function()
if not game.Workspace.HammerBasement:FindFirstChild("MainDoor") then
script.Parent:Destroy()
end
end)
This basically fires whenever a Child gets removed.
Also, your code would error and it would give you a message along those lines:
“Line 1 - MainDoor is not a valid member of HammerBasement” as it doesn’t exist, it got removed.
So you have to use FindFirstChild, as it returns nil if it can’t find the child instead of erroring.