Derma menu button help

I am new with derma menues, i managed to setup a derma menu that pops up when you press “e” on my money printer, i managed to add a button,
Now my next step is to start setting the buttons up, i managed to add a chatprint when you press on the button, but that wasnt my goal.

Now i come here to get some help with setting a button up.

button.DoClick = function()
print( "test" )

end

I want the button to mute the money printer when i press on it, but i am simply stuck in this.
i’ve tryed.

button.DoClick = function()
ent.sound:Stop()
self:Remove()

end

But i am doing it wrong, so could anyone help me to get further with this?

You can’t do it clientside, or atleast it won’t turn off for everyone.
What you need to do:



// serverside:
util.AddNetworkString( "identifying name for the purpose" );

net.Receive( "identifying name for the purpose", function( len )

    local _e = Entity( net.ReadFloat() );
    _e.sound:Stop();

end );
// clientside:
button.DoClick = function()

    net.Start( "identifying name for the purpose" );
    net.WriteFloat( entity index that you want to modify, ent:EntIndex() );
   
net.SendToServer();

end


this has many missing things such as checking entity is valid and if player is actually next to the entity(if required), if ent has the stop() and is a money printer but you get the idea.

Yeah thanks for the help Busan i apreciate it a lot, but i still don’t get it.

I assume you use ENT:Use( player ) to send to client to open the Derma?
Please post your ENT:Use() code and the full clientside derma and I can write the code.

I use

function ENT:Use( ply, caller )
umsg.Start( “DrawTheMenu”, ply )
self:SetUseType(SIMPLE_USE)
umsg.End()
end

and my derma menu

local function DrawTheMenu()
local Frame = vgui.Create( “DFrame” )
local button = vgui.Create(“DButton”,Frame)
Frame:SetTitle( “Saphire Printer Menu” )
Frame:SetPos( ScrW()/2 - 225, ScrH()/2 - 100 )
Frame:SetSize( 350, 350 )
Frame:Center()
Frame:ShowCloseButton(true)
Frame:SetDraggable( false )
Frame:SetSizable(false)
Frame:SetDeleteOnClose(true)
Frame:MakePopup()
Frame.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 240 ) )
end

button:SetParent(Frame)
button:SetText( "Sounds Stop Upgrade" )
button:Center()
button:SetTextColor( Color(255, 255, 255) )
button:SetPos( 20, 40 ) -- place
button:SetSize( 310, 40 )
button:SetImage( "materials/custompicture/here/redglow1.png" )
button.Paint = function( self, w, h )
draw.RoundedBox(0, 0, 0, w, h, Color(127, 0, 0, 250) ) -- Draw a blue button
end	
button.DoClick = function()
ent.sound:Stop()
self:Remove()
end

end
usermessage.Hook( “DrawTheMenu”, DrawTheMenu )