Absolute position is offseted

i want the outlike thing centered at the little tool hotbar thing however… it doesnt. the anchor point is the same and sine the little trowel thing is in a canvas group for other reasons. i tried to use this code to get the absolute pos and size. only the size seems to work

code:

function object:ItemActivate(Number, cooldown)
	local ItemList = self.Hotbar.ItemList
	local GuiItem = RealItemList(ItemList)[Number]
	
	GuiItem.Frame.Size = UDim2.fromScale(1, 1)
	
	local InvisFrame = GuiItem:Clone()
	InvisFrame.Parent = ItemList.Parent
	
	InvisFrame.BackgroundTransparency = 1
	InvisFrame.Frame.BackgroundTransparency = 1
	InvisFrame.ImageF:Destroy()
	InvisFrame.Position = UDim2.fromScale(0,0)
	InvisFrame.Position = UDim2.fromOffset(GuiItem.AbsolutePosition.X, GuiItem.AbsolutePosition.Y)
	InvisFrame.Size = UDim2.fromOffset(GuiItem.AbsoluteSize.X, GuiItem.AbsoluteSize.Y)
	print(InvisFrame.Position)
	game:GetService("Debris"):AddItem(InvisFrame, .7)
	
	
	local Border = Instance.new("UIStroke")
	Border.Parent = InvisFrame
	Border.Color = ToolM.TColors[GuiItem.Name].First
	
	TS:Create(InvisFrame, TweenInfo.new(.5, Enum.EasingStyle.Exponential), {Size = UDim2.fromOffset((GuiItem.AbsoluteSize.X + 10), (GuiItem.AbsoluteSize.Y + 10))}):Play()
	
	local CoolDownAnim = TS:Create(GuiItem.Frame, TweenInfo.new(cooldown, Enum.EasingStyle.Sine), {Size = UDim2.fromScale(1, 0)})
	CoolDownAnim:Play()
	CoolDownAnim.Completed:Wait()
end

yea because of the GuiInset that roblox doesnt seem to fix the absoluteposition to align with it, but u can get through this by adding a frame with 1x1 pixel size, put it inside a screengui with ignoreguinset enabled, put the position to 1,1 so its in topleft, then the absoluteposition of that will be offseted with something like (0, 0, 0, -56) so now u just have to subtract that offset with whatever you’re trying to make work in other frames

like

local DummyScreen = Instance.new("ScreenGui")
DummyScreen.IgnoreGuiInset = true
local DummyFrame = Instance.new("Frame")
DummyFrame.Size = UDim2.fromOffset(1,1)
DummyFrame.Parent = DummyScreen
DummyFrame.Position = UDim2.fromOffset(1,1)

local XOffset = DummyFrame.AbsolutePosition.X
local YOffset = DummyFrame.AbsolutePosition.Y

I believe AbsolutePosition denotes the top-left corner of an object—regardless of its AnchorPoint. Therefore, you can align the outline by centering its AnchorPoint and adding half the target frame’s AbsoluteSize.

local Offset = GuiItem.AbsolutePosition + GuiItem.AbsoluteSize/2
InvisFrame.AnchorPoint = Vector2.new(0.5, 0.5)
InvisFrame.Position = UDim2.fromOffset(Offset.X, Offset.Y)
1 Like