I am trying to position a frame to another frame’s position that is inside of a frame. It calculates correctly on the X axis but not on the Y.
local xOffset = target.AbsoluteSize.X * frame.AnchorPoint.X
local yOffset = target.AbsoluteSize.Y * frame.AnchorPoint.Y
local targetPos = target.AbsolutePosition + Vector2.new(xOffset, yOffset)
local newPosition = UDim2.fromScale(targetPos.X / gui.AbsoluteSize.X, targetPos.Y / gui.AbsoluteSize.Y)
frame.Position = newPosition
Just to confirm - is gui
the parent of frame
?
1 Like
local gui = script.Parent
local frame = gui.Frame
local target = gui.MainFrame.Frame
all i had to do was subtract the gui absolute position and it always works!
local xOffset = target.AbsoluteSize.X * frame.AnchorPoint.X
local yOffset = target.AbsoluteSize.Y * frame.AnchorPoint.Y
local targetPos = target.AbsolutePosition - gui.AbsolutePosition + Vector2.new(xOffset, yOffset)
local newPosition = UDim2.fromScale(targetPos.X / gui.AbsoluteSize.X, targetPos.Y / gui.AbsoluteSize.Y)
frame.Position = newPosition
system
(system)
Closed
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.