You need to check out www.inductiveuniversity.com, it is a free website of learning materials including scripting. Here is a link to Ignition Scripting Functions. Scripting is done in Jython language, which is pretty much python 2.7 with access to some java classes/methods.
tagValue = system.tag.read('[default]Carrier States/Carrier_001').value
if tagValue == 9:
newValue = 0
else:
newValue = 9
system.tag.write('[default]Carrier States/Carrier_001',newValue)