Derma Checkbox keeps unchecking

Hi Guys,

I am currently working on my first addon and would like to polish some stuff. There is a debug mode for admins, that can be checked via a Derma Checkbox. However, every time I reopen the menu, the checkbox is unchecked whether Debug mode is on or off.

So far, I couldn’t fix this issue myself. Could you help me with this?

Thanks in advance!


Can you show your code?

Just the standard stuff,

function OpenAdminGUI()

    local AdminGui = vgui.Create( "DFrame" )
    AdminGui:SetPos( ScrW() / 2, ScrH() / 2 )
    AdminGui:SetSize( 500, 400 )
    AdminGui:SetTitle( "Pre Round" )
    AdminGui:SetVisible( true )
    AdminGui:SetDraggable( true )
    AdminGui:ShowCloseButton( true )

    DebugCheckbox = vgui.Create( "DCheckboxLabel" , AdminGUI )
    DebugCheckBox:SetPos( 15, 110 )
    DebugCheckBox:SetText( "Debug Mode?" )
    DebugCheckBox:SetValue( fValue )
    DebugCheckBox.OnChange = function( pSelf, fValue )
        debugmodeactive = fValue
        if debugmodeactive == true then
            RunConsoleCommand( "ActivateDebugMode" )
        else RunConsoleCommand( "DeactivateDebugMode" )

Have I forgotten something? Keep in mind that switching it on and off works perfectly, but it’s annoying having that box unchecked all the time even though Debug mode is on.

If you’re assigning fValue inside that function, it’ll set itself each time the function runs; make sure you aren’t doing that.

DebugCheckBox:SetValue( fValue )

Where do you set the value of fValue?