GetPosition of a frame on a another frame

Hi, i post this here because i need help about moving a frame to another frame position that is in another frame.

I will give a visual exemple of what i try to do:

I try to move a Frame (Frame1) to another frame position (Frame2) that inside another frame (FrameRed&FrameBlue) so its parent is not the same size and not the same position

I try look into the devforum but a don’t find anything
i try use AbsolutePosition but it’s say is only get and not set
i try convert to offset and after to scale but is not worked how i wanted (probably bad coding)

Video of what i want : (i don’t ask for get movement only that i want the frame to go to the other frame position)

(I’m already aware that I posted a similar forum 3-4 days ago but I don’t have an answer and I really need an answer to continue my project)

uhh… i don’t correcly understand what you say (i still learn english) but i think is yes

Get the absolute position of frame 2 (the one u will be moving to), set the other frame (the one you will move) to the position, you can change to scale if u want later but not really needed.

oh!! i will try this and tell you if is work

1 Like

i try and i get a problem, is if the frame is inside the red frame is just leave the screen and start a the wrong position but if is on on the full screen size is moving corretly, how i can fix this ?

(Purple frame is direcly parent to the screengui)

I don’t get what you mean but can you show me the code?

Edit: nvm I understood what you meant.

yeah sorry i was thinking showing the code:

local AbsolutePositionFrame2 = script.Parent.BlueFrame.Frame2.AbsolutePosition

print(AbsolutePositionFrame2)

local A = script.Parent.RedFrame.Frame1.AbsolutePosition
local B = script.Parent.Frame3.AbsolutePosition

local ClonedA = script.Parent.RedFrame.Frame1:Clone()
local ClonedB = script.Parent.Frame3:Clone()

ClonedA.Parent = script.Parent.RedFrame
ClonedB.Parent = script.Parent

for i = 1,200 do
	
	local Result1 = A:Lerp(AbsolutePositionFrame2,i/200*1)
	local Result2 = B:Lerp(AbsolutePositionFrame2,i/200*1)
	
	print(Result1)
	print(Result2)
	
	script.Parent.RedFrame.Frame1.Position = UDim2.new(0,Result1.X,0,Result1.Y)
	script.Parent.Frame3.Position = UDim2.new(0,Result2.X,0,Result2.Y)
	
	wait()
	
end

Can you set the position of the green frame (inside the red one) to 0,0,0,0 and send a pic? No need for code but I just want to check something, I’ll continue reading your code while u finish.

And show me the output.

like this ?

i don’t edit the code

Not exactly but it’s good enough. I’ll try to find the problem

ok and thank you so much for help me :smiley:

1 Like

The problem is the pink frame is not inside another frame therefore absolute position works but the green one is inside a frame and the position will therefore be relative to that frame.

That’s why I asked for the 0,0,0,0 position, now I’m thinking of a way to move it correctly.

Maybe if you took the frames parent position + the frames position and do some kind of multiplication with anchor point

@Natchxel try that and show us the results.

@Natchxel I think I got it…
When changing the position do:
calculated position * viewport size / parent size
If the parent is a screenGUi or something then no need to do this calculation.

something like this ?

local A = script.Parent.RedFrame.Frame1.AbsolutePosition * workspace.CurrentCamera.ViewportSize / script.Parent.RedFrame.AbsoluteSize

Yes. ..

Green is no longer on the screen:

local AbsolutePositionFrame2 = script.Parent.BlueFrame.Frame2.AbsolutePosition

local A = script.Parent.RedFrame.Frame1.AbsolutePosition * workspace.CurrentCamera.ViewportSize / script.Parent.RedFrame.AbsoluteSize
local B = script.Parent.Frame3.AbsolutePosition

local ClonedA = script.Parent.RedFrame.Frame1:Clone()
local ClonedB = script.Parent.Frame3:Clone()

ClonedA.Parent = script.Parent.RedFrame
ClonedB.Parent = script.Parent

for i = 1,500 do
	
	local Result1 = A:Lerp(AbsolutePositionFrame2,i/500*1)
	local Result2 = B:Lerp(AbsolutePositionFrame2,i/500*1)
	
	warn("Result1(frame green):")
	print(Result1)
	warn("Result2(frame purple):")
	print(Result2)
	warn("------------")
	
	script.Parent.RedFrame.Frame1.Position = UDim2.new(0,Result1.X,0,Result1.Y)
	script.Parent.Frame3.Position = UDim2.new(0,Result2.X,0,Result2.Y)
	
	wait()
	
end

i gonna go afk during like 30min for eating

1 Like