:Removed() not removing some of the VGUI

Another quick question! When you click the DButton, it’s meant to remove ‘fullpage’ and anything that is a child of it. However it only seems to be removing the DButton’s themselves.


function Chat( talkerName, message, filepath, replies, repliesTableCount)
    fullpage = vgui.Create( "DButton" );
         -removed   

    background = vgui.Create( "DPanel", fullpage);
         -removed

    TalkerName = vgui.Create( "DLabel", fullpage )
         -removed

    MessageContent = vgui.Create( "DLabel", fullpage )
         -removed

    replyPosition = 160
    for k, v in pairs( replies ) do
        reply = vgui.Create( "DButton", fullpage );
        reply:SetSize( (ScrW() * 0.75 ) - 250, 40) 
        reply:SetPos( ((ScrW() / 2) - ((ScrW() * 0.75 ) - 250) / 2), replyPosition )
        reply:SetText( v.responsemessage );
        reply:SetTextColor( Color( 255, 255, 255, 255 ) )
        reply:SetContentAlignment( 7 )
        reply:SetDrawBackground(false)
        reply:SetDrawBorder(false)
        reply:SetFont( "MessageContent" )
        replyPosition = ( replyPosition + 45 )
        reply.DoClick = function( reply )
            fullpage:Remove()
            print( v.responsemessage )
            net.Start( "chosenReply" )
                net.WriteString( v.responsemessage )
            net.SendToServer()
        end
	end
end

Note: I’ve removed anything that is un-needed as it was cluttered.

Why are you using DButton as a parent panel anyway? Use DPanel or DFrame instead.

[editline]10th May 2014[/editline]

Also, localize your variables

DButton only because I needed to easily do something when users click on the screen when all these VGUI elements are activated.

Yes, I need to localize them :slight_smile: Do you know why it won’t remove them though? I have tried switing DButton to DFrame to see if it was the issue, but it wasn’t.

Probably because fullpage is not what you think it is. It might be overridden by something, maybe even the same script. Localize your variables and don’t use DButton as parent panel. Report back AFTER you have done BOTH of those things.

Think I’ve found the issue, which I’ll added just shows how important it is to paste your whole script when asking for help :slight_smile:

I get all the variables for net.Receive, and then on the last net.Receive call the Chat function with all the variables, however I was calling it twice, once without the replies and once with, which is why when I deleted it, the replies disappeared but not the rest, cause it was still there from the first function call.

Thanks for the help guys!

[editline]10th May 2014[/editline]

Ye, all worked. Solved: )