So, the issue is that you’re using util.AddNetworkString is what appears to be a CLIENT file.
vgui is client-side. Declare the net string in a proper server file.
next, net.Start is fine, net.Send is a server command. The client has the command to SendToServer, use that.
Then, on the server, where you declared the network string, add the net receiver where you do something.
Here’s a TTT script I give out. It should help you understand networking a bit better; I’ll explain it below.
So Trouble In Terrorist Town has a few SERVER side hooks. Ignore those, and just imagine all the stuff in sv_ is server side as it is. the hook “TTTEndRound” on the sv file is what starts the entire process.
Ignore that it’s wrapped in if ( SERVER ), it’s not necessary but there to make it more clear for people that put it in the wrong area.
So, you see the network string on line 28, and from 46 to 48 is where it sends a message to every player on the server using Broadcast. The message it sends is a simple string. There are more efficient ways to do this, but for learning it’s fine.
on the cl_ file, you’ll see the network receiver for the network string declared on line 28 and sent on line 48 of the sv file.
it reads the string which was sent ( note that all net stuff needs to be read in order, otherwise you’ll improperly cast a variable ) and then it plays the sound.
What you’re trying to do is similar. Instead of the server initializing it via hook, you initialize 46-48 via button press and instead of Broadcast, you need SendToServer. You may not need the write string on 47 unless you target a user, so some data may be required.
the net receiver on the cl file, is pretty much exactly what you need to put on the server-side receiving the message. You may want to change the message name, and obviously the contents aside from read string unless you keep it.
You can set up a chain of these messages.
Try this: on click, SendToServer a message, when the server net.Receive’s that message, net.Broadcast the same message from the server. On the client, receive the message, and send the same message via SendToServer with a string reading final. Have your net.Receive on the server constantly send Broadcast until final is received. Have the client send final to the server.
Experiment with that. Edit the file and remove the write string from the client side, and you’ll see that the server will spam the client, it’s because these can be set up in recursive loops; not advisable in a real environment unless you know what you’re doing, have a time in between and use it as a ping or something.