Positioning a frame with AbsolutePosition

I have two TextLabels and want to calculate the Middle between them. Since they are under a UIListLayout, I can’t access the Position of the TextLabel and have to use the AbsolutePosition instead. My goal is to put a frame between them.

I have tried various ways, but the frame always moves somewhere where it shouldn’t move.

local lastSurvivorLabel = LeaderboardPlayer:FindFirstChild(lowestSurvivor.."_Place").AbsolutePosition
local highestVictimLabel = LeaderboardPlayer:FindFirstChild((lowestSurvivor + 1).."_Place").AbsolutePosition

SurvivedLine.Position = UDim2.new(???) 

Screenshot 2023-10-02 193123

The red line is the frame that I want to move.

Thanks for any help!

2 Likes

Iirc you can’t change absolute coordinates. However you can get the absolute position of frames parent and subtract that from the target absolute position. Then you can set the value of the frames position to the calculated value by using Udim2.fromoffset or something.

4 Likes

Why not just use the ListLayout for your advantage?
Just set the frame LayoutOrder between the 2 text label you want set it in

1 Like

he doesn’t do this because it creates a gap I think.

1 Like

He can “hack” his way through this by scaling it down

1 Like

True. He could also skip a number for the layout order for every entry to make it easier to code. (1 → 1, 2 → 3, 3 → 5 etc. and then have the “bar” located at each layout order + 1)

1 Like

Thanks, guys!

I figured out how to do it. I created a new UIListLayout because, as FartFella mentioned, it scales the frame down.
Then I added several PlaceHolders with starting numbers 1 - 9 and changed the sort order of the UIListLayout to Name.

The script now changes the name of SurvivorLine to Number of last survivor + 1 and a 0 after the number. This puts the frame directly after the name of the last survivor.

Screenshot 2023-10-02 204103
Screenshot 2023-10-02 204918

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