# Network.sendToServer

Sends a network event from the client to the server. This will run the callback method on the server with optional arguments.

**Kind:** Function

**Environments:** Game

## Game

``` { .lua .api-signature }
network:sendToServer( callbackMethod, args? )
```

[Open the full Game reference](../Game-Script-Environment/Userdata/Network.md#sendtoserver)

**Availability:** Client only

```lua
-- Example of calling server function over network, called function receives the optional argument and the sending player
function MySwitch.client_onInteract( self ) 
	self.network:sendToServer( 'server_setSwitch', { active = true } )
end

function MySwitch.server_setSwitch( self, args, player ) 
	-- Set state of switch
	self.interactable.active = args.active
end
```

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `network` | [Network](../Game-Script-Environment/Userdata/Network.md) | The network. |
| `callbackMethod` | string | The server function name. |
| `args` *(optional)* | any | Optional arguments to be sent to the server. |
