How would I move a label parented to a SQUARE aspect ratio'd frame to your mouse cursor? [URGENT]

I’m trying to make a placement system for my game, but I can’t figure out how to move a frame to the cursor parented to a square-shaped frame. I reuploaded this because NOBODY helped me.

1 Like

sorry not entirely sure what you mean, would something like this work?

while true do
    frame.Position = cursor.Position
end

seems too simple but let me know

2 Likes

Do you need to add a Aspect Ratio constraint to your UI? It’s very difficult to tell what you want to do, even more difficult to tell what you are having trouble with. Can you share a script and outline which part you think isn’t working and what you expect it to do?

1 Like

@Drixitty @gertkeno The frame already has a UIAspectRatioConstraint to it, and I want to move a label that is parented to that frame to be moved to the mouse cursor. I also need to convert the frame position into a scale position.

1 Like

what frame is it parented to? i dont quite understand the demonstration above

2 Likes

To convert frame position to size use the AbsoluteSize and AbsolutePosition properties. We can convert the aboslute positions into a 0-1 scale

local function to_scale(placeable: Frame, frame: Frame): UDim2
    local x = (placeable.AbsolutePosition.x - frame.AbsolutePosition.x)  / frame.AbsoluteSize.x
    local y = (placeable.AbsolutePosition.y - frame.AbsolutePosition.y) / frame.AbsoluteSize.y

    return UDim2.new(x, 0, y, 0)
end
1 Like

So correct me if I’m wrong, you want to make it so the GUI object is locked to the cursor and when the cursor moves, the GUI object moves along with it? (Basically dragging the object with your cursor just like you would if you were moving files in your computer’s desktop)

1 Like