FloatProperty that scales one axis

I am trying to add some functionality to the blender UI. I’ve added a simple FloatProperty with a min and a max value. I want to set it up so that when the FloatProperty is adjusted, the currently selected object is scaled in the X axis to match the value being set. But, I can’t for the life of me figure out how to do this!

Try this code:

bpy.types.Scene.XScale = bpy.props.FloatProperty(
            name = "XScale", 
                 description = "Sets the active objects scale on the x-axis",
                 min = 1,
                 max = 20,
                 default = 2,
                 update = setscale)


def setscale(self, context):
         scene = bpy.context.scene
         selobj = bpy.context.active_object
         selobj.scale[0] = scene.XScale

If you have any questions about this code and how it works, feel free to ask!

Thanks!!!