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)
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.
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 ?
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.
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.
@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.
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