How to obtain the absolute position of an ImageButton on the screen

I’m trying to obtain the absolute x, y position on the screen of an ImageButton.

But

print(game.StarterGui.ScreenGui.MyFrame.MyImageButton.AbsolutePosition)

shows

attempt to index function with ‘AbsolutePosition’

How can I get the absolute x, y position on the screen of an ImageButton?

1 Like

print(tostring(game.StarterGui.ScreenGui.MyFrame.MyImageButton.AbsolutePosition))

1 Like
local object = script.Parent -- parent being the Gui object
print(object.AbsolutePosition.X, ",", object.AbsolutePosition.Y)

image

Edit:

If you put the script under the GuiObject you want it to print the AbsolutePosition for, that’s just what it’ll do…

1 Like

That’s the parent’s position, not the ImageButton position…

1 Like

It’s a place holder you can change the script.

1 Like