> For the complete documentation index, see [llms.txt](https://rocket-networking.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rocket-networking.gitbook.io/docs/server-side-scripting/send-event-to-a-client-from-server.md).

# Send Event to a Client from Server

On every Game Instance there is a method called **SendEventToClientFromServer**. This allows you to send a message to any client from the server, you just need to know thier client id.

<pre class="language-javascript"><code class="lang-javascript"><strong>game.SendEventToClientFromServer(RclientId, eventName, messageStruct)
</strong></code></pre>

## Example Implementation in the "client\_sent\_event"

Shoutout to Komatr for improving the docs!

<figure><img src="/files/cwgTuK5pU6P5egNx11if" alt=""><figcaption></figcaption></figure>

<pre class="language-javascript"><code class="lang-javascript"><strong>//Example Implementation, in the "client_sent_event" script
</strong>switch(eventName){
    case "chat":

    var chatMessage = messageStruct.chatMessage //sent by client
    chatMessage = CussWordsFilter(chatMessage)  //some function to clean cuss words
    
    //now send this chat to everyone in the room
    //firstly find the room this sender belongs to, then send the message to everyone
    for(var roomId in game.rooms){
        if(game.rooms[roomId].clients.hasOwnProperty(senderClientId){
            //we found the sender
            //now send the message to everyone here
            for(var clientId in game.rooms[roomId].clients){
                //make a messageStruct to send everyone
                var a = {
                    message: chatMessage,
                    sender: clientId
                }
                game.SendEventToClientFromServer(clientId, "cuss_free_chat", a)
            }
        }
    }
    break;
    
  
}
<strong>
</strong></code></pre>
