How to make VGUI buttons effect an entity.

I’m good at lua but noob at gmod lua, as I understand GUI is ran clientside, I also presume that the command you enter in Button:Clicked is ran clientside. If I put the Button:Clicked statements in the server side file would it still work? I’m trying to change a variable on an entity, so far you click E and a box pops up, still working out buttons though because of this issue. Advice?

All vgui is clientside. You’d write the function button:DoClick( ) // button.DoClick = function( ) // etc… on the client, but you’d network the data to the server.

net.Start( “Name” );
net.WriteX( );
net.SendToServer( );

Make sure util.AddNetworkString( “Name” ); is added on the server, along with a net.Receive( “Name”, function( len, ply ) … end );

Then you can have the button do something on the server.

Awesome thanks! I thought I would have to utilize something networky!

If you’re unsure of how to set it up, here’s an example just networking booleans: https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua.html

I believe a new net function may have been made for that since that was written, but it should show the basics. I’ll work on getting a few more networking tutorials up ( been busy getting ready to release a few large meta-table / objects on my dev base including a lightweight networking system, sql query builder, fileio and a few other things.