Closing DFrame using Function

Hi, i am trying to make a function (closeList()) that will close a DFrame that is in the function createHitList(). It keeps saying close is a ‘nil’ value. Notice i have list.Close() but i have tried list:Close() also and it doesnt work. I do not want SetVisible as an alternate.


function createHitList()

	local width, height = ScrW() * 0.175, ScrH() * 0.4;

list = vgui.Create("DFrame");
list:SetSize(width, height);
list:SetTitle("Hit List by pablo67340");
function list:Paint( w, h)
end
function closeList()
list.Close()
end

Because you aren’t really running the function on a frame.
Do List:Close() instead, or List:Remove()