The nesting of the first snippet of code is ridiculous. You should really narrow that down.
If youâd bother to explain what you (guys) are trying to do step by step, itâd be a little easier to understand.
What I got from this was:
- Player(1) presses a button on a menu.
- Gets sent to the server. (Via a net message Iâd assume?)
- Gets re-broadcasted (again, via a net message?) to every player and goes through the original snippet you posted.
A better way to go about this would be like:
- Player presses button.
- Sent to server, goes through the checks - in a more efficient manner.
- Run player:ChatPrint(msg) serverside instead of sending it via another net and clogging net space with garbo.
Example:
--Client
Button.DoClick = function()
net.Start("CL_Message")
--Write whatever data is needed (idk if there was any)
net.SendToServer()
end
--Server
util.AddNetworkString("CL_Message")
net.Receive("CL_Message",
function(len,ply)
--Read Data
--Run through the checks
v:ChatPrint() -- Chat Print
end)
Edit:
For further explanation, basically itâs not working because youâre trying to send a message from a client directly to other clients.
The only way that itâll work is if you send it from the server or use the method I provided above.