Enable and Disable Button Help!

Hello everyone, i’m trying to make a lua script that makes me a gui where i can enable and disable a bhop script. I have the bhop script enable button working, but I don’t know how to make the disable button / how to make it stop reading the enable button lines until its enabled again. Does anyone know what I should do to the disable button to make it stop the bhop until I press enable? Thanks :slight_smile:

[lua] local me = LocalPlayer()

local Frame = vgui.Create( “DFrame” )
Frame:SetTitle( “Moo Hack – Wiggle” )
Frame:SetSize( 300, 300 )
Frame:Center()
Frame:MakePopup()
Frame.Paint = function( self, w, h ) – ‘function Frame:Paint( w, h )’ works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 128, 128, 128, 100 ) ) – Draw a red box instead of the frame
end

local Button = vgui.Create( “DButton”, Frame )
Button:SetText( “Enable BHOP!” )
Button:SetTextColor( Color( 255, 255, 255 ) )
Button:SetPos( 25, 250 )
Button:SetSize( 100, 30 )
Button.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 238, 0, 130, 250 ) ) – Draw a purple button
end
Button.DoClick = function()
if me:IsOnGround() and input.IsKeyDown( KEY_SPACE ) then
RunConsoleCommand("+jump")
else
RunConsoleCommand("-jump")
end

end

local Button = vgui.Create( “DButton”, Frame )
Button:SetText( “Disable BHOP!” )
Button:SetTextColor( Color( 255, 255, 255 ) )
Button:SetPos( 175, 250 )
Button:SetSize( 100, 30 )
Button.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 238, 0, 130, 250 ) ) – Draw a purple button
end
Button.DoClick = function()

end
end

[/lua]

You don’t need two buttons for that, just change the button text in the doclick function and then add a bool with a if statement to act as a toggle.

do you think you could edit my code and show me :3. I’m trying to look for the right boolean on the fourms. but i’m pretty new to source lua.

use the “ihop” script, which many scripts include, it got a basic boolean function in it.

I’m not a big fan of writing code for other people, if you don’t know how to use a bool for a if statement you should really learn lua before learning GLua.

If you wrote the code above, you shouldn’t need an example and you’ll learn more by doing it on your own

If you modify this part at any time after the button is made, the text will change:



Button:SetText( "Enable BHOP!" )


So you could change to ‘Disable BHOP!’ very easily. I see an elseif statement in that code so you know how to do them, all you need to do is create your own variable like isbhopping then set it to true/false