How do I sync a flashlight over the network?

I have multiplayer working, but I have no clue/code on how to sync the flashlights. I’m using a spotlight attached to the main camera for each player and it’s always on over the network. First question, sorry if I missed anything.

Basically I want to sync each players component status over the network. My script which works for each player (players over network can’t see them turning it on and off, but everyone can turn their flashlight off) sets the light intensity to 0, then 1.5 when it’s turned back on. Is there any way to sync this over the network?

Each player needs to receive the information with the on/off state of that particular flashlight, when it is changed. This is either done through State Synchronization (usually for stuff like position that is always changing) or with a remote procedure call (RPC).

I’d recommend using an RPC, since I’m assuming this event only happens occasionally. The RPC would invoke a function on all players machines that turns that specific flashlight off or on. If you are using an authoritative server setup, you would likely first want to send an RPC to the server that you are turning your flashlight on, and then if that’s okay with the server, it would send RPCs to you and other players, that turn it on: