How would I align these 2 frames in a script via x or y axis if it is close enough

  1. What do you want to achieve?
    I am making a UI creation system, where players can make their own ui layouts and to make it easier for them I would like to make 2 frames snap onto each other and align if they are close enough to each other, just like how UI works in studio.

  2. What is the issue? Include screenshots / videos if possible!
    image
    These are my 2 frames and I have no idea how to check if they are right next to each other due to their position using offset and scale.
    image
    image

  3. What solutions have you tried so far?
    I have attempted to look for solutions in the dev forum but I only ever come up with aligning via studio, not a script

1 Like

AbsolutePosition and AbsoluteSize is for this. These give you the object’s position and size on the screen. If the distance between x or y coordinates (when evaluated separately) of each frame is bigger than their AbsoluteSize of that same axis then they don’t touch, if it’s equal they touch, if it’s smaller then they are inside of each other.

1 Like

Oh I didn’t know those values existed thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.