I hope you find this article helpful.
if: Agent := GetPlayspace().GetPlayers()[0] then: SwitchDevice.ToggleState(Agent)