Skip to main content

Network events

SendCustomNetworkEvent runs a public, parameterless method on other players' copies of the script. Use it for moments (a sound, an effect, a ping) rather than state: state belongs in [Synced] fields, so late joiners get it.

public void PlayChime()
{
chime.Play();
}

public void OnButton()
{
SendCustomNetworkEvent(NetworkEventTarget.All, nameof(PlayChime));
}
TargetRuns on
NetworkEventTarget.Alleveryone, including you
NetworkEventTarget.Otherseveryone except you
NetworkEventTarget.Ownerthe object's owner only
NetworkEventTarget.Selfonly you (same as SendCustomEvent)
  • You do not need ownership to send a network event.
  • Methods whose name starts with _ cannot be called over the network.
  • Players who join later do not receive past events.