# 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="https://1224219250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvYO9I4EKmgDF783aI7J4%2Fuploads%2FkXOmXxdRxO8gdwM7rmBF%2Fimage.png?alt=media&#x26;token=f131c637-cc54-441c-a004-f2b31f162a33" 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>
