AbsolutePosition is offset

I am trying to create a pet menu where when the player clicks on the pet it causes a pet info frame to appear which displays key information about the pet.

In order to position the pet info frame to where the pet clicked on is, I am getting the absolute position of the pet GUI and then setting the position of the pet info frame to that absolute position, however when I do this it is not accurate:

This is the code I am using to perform this task:

local function onTemplatePress(temp)
    --petInfo is the information frame that pops up
    --temp is the pet image clicked on
	petInfo.Position = UDim2.fromOffset(temp.AbsolutePosition.X,temp.AbsolutePosition.X-inset.Y)
	petInfo.Visible = true
end

If this helps, this is the organisation of my GUI elements:
image
Template = the pet images that show up in the scrolling frame
petInfo = the frame that pops up when you click on a pet

If anyone knows why this is occurring or a better way of approaching this it would be a great help!

I recently came across this problem and after a few tests I was able to solve it. I discovered that the offset position is still influenced by the Parent, so by subtracting the AbsolutePosition of the button from the AbsolutePositon of the petInfo’s parent (which must be the same parent as the list, in this case ‘petsMenu’), you’ll get the offset position you want. Then you can add the AbsoluteSize.X of the button by moving it to the right.

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