Never used this before, but it looks like this works. Two simple scriptcards below. The first creates a string variable "MyStr" and then stores it to the State object. The second retrieves the string variable from State, writes it to a new string variable "RetrievedStr", and prints it to chat. Store string variable: !scriptcard {{
--&MyStr|I stored this string
--+String to store to State object|[&MyStr]
--~MyStr|stateitem;write;stringvariable
}} Retrieve string variable and print: !scriptcard {{
--~RetrievedStr|stateitem;read;stringvariable
--+String retrieved from State object|[&RetrievedStr]
}} Same examples, but storing a roll variable: !scriptcard {{
--=MyRoll|1d20
--+Roll to store in State object|[$MyRoll]
--~MyRoll|stateitem;write;rollvariable
}} Retrieving a roll variable: !scriptcard {{
--~RetrievedRoll|stateitem;read;rollvariable
--+Roll retrieved from State object|[$RetrievedRoll]
}} Remember, only one variable of each type (roll & string) can be stored at any one time.