Help for Vgui Progress Bar

Hello,
I need some help for a Vgui progress bar. I would like to make a frame, but i’d like to add a progress bar activable with a button.
I make this and this work.
But the problem is that the progress bar doesn’t disappear when I close the windows. So i try this but it doesn’t work :



	function frame.OnClose()
		ProgressBar.Remove()
	end


And this too :



	function frame.OnClose()
		ProgressBar.Close()
	end


Could you help me please ?

Can I see the whole source code? I can’t help much if I don’t even know how you are drawing the progress bar.

yes :




nclude('shared.lua')

net.Receive( "MyNpcFunction", function()

	local frame = vgui.Create( "DFrame" )				-- Main Frame
	frame:SetTitle("Title")
	frame:SetSize( 800, 800 )
 	frame:Center()
	frame:GetBackgroundBlur()
	frame:MakePopup() 	
	frame.Paint = function( self, w, h ) 
		draw.RoundedBox( 0, 0, 0, w, h, Color( 50, 50, 50, 150 ) )
	end
	function frame.OnClose()						-- PROBLEM HERE
		ProgressBar:SetFraction( 0 )
		ProgressBar.Remove() 					-- Or Close but it doen't work too...
	end
	
	local ProgressBar = vgui.Create( "DProgress" )		-- Progress Bar
	ProgressBar:SetPos( 600, 500 )
	ProgressBar:SetSize( 400, 30 )
	ProgressBar:SetFraction( 0 )
	
local i=0
	
	local Button = vgui.Create( "DButton", frame ) 		-- Button
	Button:SetText( "Progress Bar Start" )					
	Button:SetPos( 250, 500 )		
	Button:SetSize( 250, 30 )					
	function Button.DoClick()
		print( "[DARKRP] Progress..." )
		timer.Create( "TraitementBar", 0.3, 100, function()
			i = i+0.01
			ProgressBar:SetFraction( i )
		end )
	end
	
end )




Set the parent of the DProgress to the DFrame.

Thank you very munch,


ProgressBar:SetParent( frame )

work !

It’s the second argument of

vgui.Create.

-snip-

Got ninja’d :frowning:

The second argument needs to be a panel, not a string.

Yes, my bad I had just woken up.

Also, have in mind next time that it isn’t


ProgressBar.Remove()

but rather


ProgressBar:Remove()

Notice the two dots. One is a reference to an object/entity/table and the other isn’t, as it needs to take the panel as a parameter to be able to get removed.