Converting Offset Position To Scale Position?

How do I convert Offset Position To Scale Position?

Child.Position = UDim2_New(Child.AbsolutePosition.X/Parent.AbsoluteSize.X,0,.085,0)

It doesn’t work quite well, the Math Formula is missing something

I did found this thread but it’s unsolved

2 Likes

Oh, I see what you mean. If you want to take the parent’s position into account, just subtract it out from the new scale:
Child.Position = UDim2_New((Child.AbsolutePosition.X - Parent.AbsolutePosition.X) / Parent.AbsoluteSize.X,0,.085,0)

6 Likes

I still have the same problem.

If you put a wait between your line setting the position in offset and the one converting it to scale, you’ll see that it’s not an issue with the conversion itself; there’s something wrong with what’s determining the offset position. Also, in your repro there’s nothing named “Child,” but I assume the TextLabel was supposed to be named that?

2 Likes

You can’t set a value as a condition. I’m not sure what you’re trying to do there.

1 Like

I see,

line 9 is working fine
Child.Position = UDim2.new((Child.AbsolutePosition.X - Parent.AbsolutePosition.X) /Parent.AbsoluteSize.X,0,.085,0)
there's a problem with line 8
Child.Position = UDim2.new(0,ImageButton.AbsolutePosition.X + ImageButton.AbsoluteSize.X + 5,.085,0)

How do I fix line 8?

What are you trying to do there? Do you want it to be centered around the image like this?

image

image

Do you want it to have the same corner as the image like this?

image

image

Since it’s not working, it’s hard to tell exactly what you’re looking for.

1 Like

I need the Text to be on the Right side of the Image + 5 Pixels away

I want it to look exactly like how it looks when the Parent Frame’s Position is set to (0,0,Y,Y)

Everything was working fine until I changed the Parent Frame’s Position to something else that isn’t 0 on the X Axis,

You just have to subtract out the parent’s AbsolutePosition then.
Child.Position = UDim2.new(0, ImageButton.AbsolutePosition.X - Parent.AbsolutePosition.X + ImageButton.AbsoluteSize.X + 5, .085, 0)

Since AbsolutePosition is based on the distance from the top left, it doesn’t account for the parent’s position. That’s why you have to subtract out the parent’s position in both cases; AbsolutePosition’s value has the parent’s position in it, but when you set the Position, it already offsets it based on the parent’s position.

16 Likes

Thank you, now it’s working like I want it to!



1 Like