How to get the position of a GUI Object in a UIListLayout?

Hello, I’m currently trying to get the position of a frame in a UIListLayout, which changes based on other items in the UIListLayout.

Currently, when I check the property for position, it appears that it is simply “overriden.” I understand the UIListLayout overrides setting the property but it doesn’t make sense to also override being able to read its position.

I have tried things such as predicting its position based on the sizes of objects in the UIListLayout but I find this approach doesn’t work accutely and is hard to manage.

I was wondering if anyone knew a solution to this issue

An example of how it fails:

local frame = Script.Parent 
print(frame.Position) -- {0, 0}, {0, 0}

no matter what it prints the position is {0, 0}, {0, 0} as reading the position is overriden.

AbsolutePosition

Absolute position and mouse position (offset) are not the same it appears

by the way I have been playing ur obby tycoon and noticed lag spikes. You shouldn’t load other people’s plots, only the plot that they’re currently in. This will significantly improve the games preforamance on a range of devices. Additionally, Roblox considers the average device preformance when evaluating metrics, so improving your games preformance will lead to a boost in players.

Absolute Position represents what is basically the offset as a Vector2. If it’s parent isn’t positioned at (0,0), then you could do something like this:

local Object = ...
local Frame = Object.Parent

local ObjectPos = Object.AbsolutePosition
local FramePos = Frame.AbsolutePosition

local Position = UDim2.fromOffset(ObjectPos.X - FramePos.X, ObjectPos.Y - FramePos.Y)

Regarding the lag - other players plots aren’t really ‘loaded’ much. The obbies appear, however almost nothing is moving and the NPCs of other players plots aren’t loaded. The main lag causer is the NPCs in the player’s own plot.

Perhaps for the NPCS in the plot you could use basic tweening w/ animations rather than any complex system or basic pathfinding to optomize preformance. You could also consider using one script to manage all the NPCs and simplify the parts within them.

One idea is that you are loading their friend’s avatars which causes lag so you could also try caching specific avatars rather than continuously loading them as well as centralizing the logic in a single script which manages all the NPCs.

The lag was particularly annoying when I was trying to complete the obbies as they caused me to fail in the difficult ones

It already is done with tweening (after the initial run through). The logic is also centralised and I have tried caching, which caused more problems than it solved.


Further discussion regarding it should be done in the DMs, to avoid taking the main post off-topic.