The reason is that 'x' is not an attribute, it is a variable . . .
Attributes refer to the state of the object, how it presents itself or reacts to input .
Variables are the data part of the object.
So maybe reread sections 6.9 Using containers and 10.4 Attributes.
The script for your button will be something like