How do I change the rect transform value of a slider?

I want to change the value “right” but it returns me with an error that it isnt a variable.

alt text

This is the error I get when I try to access the rect:

alt text

printing does give me a value, how can I change it through script though?

You’ll have to fetch the Rect, change the value, and reset it:

Rect rect = bg.rect;
rect.xMax = 100;
bg.rect = rect;

This has to do with Rects being structs, not objects. So when you do this:

bg.rect

you’re getting a copy of the value of the Rect, not the same rect as the one on the bg object. . Meaning that it would be completely possible to let you do this:

bg.rect.xMax = 100

but the value would just be changed on a copy that you’ve already lost access to (a new call to bg.rect would give a new copy), so the line would do literally nothing.