This might be impossible to do… What im trying to do was making a guiobject keep the pos and size as from the previous parent when reparented into another frame. Was trying to make loadout system tho
However i tried doing that in different place file then tried to convert into scale, doesnt work though.
Here’s the code for it idk how to explain more lol
local screengui = script.Parent
local c = {
frame1 = screengui.Frame1,
frame2 = screengui.Frame2,
red = screengui.Frame1.Red
}
local curRedPos = c.red.Position
local RS = game:GetService('RunService')
local timer = 0
local bool = false
RS.RenderStepped:Connect(function(dt)
if timer > 1 then
bool = not bool
timer = 0
if bool then
c.red.Parent = c.frame2
c.red = c.frame2.Red
local h = (c.frame1.AbsolutePosition - c.red.AbsolutePosition) / screengui.AbsoluteSize
-- tried this and still couldnt position to the frame1 as the scale
-- about the size i really dont know how to figure that out :/
c.red.Position = UDim2.new(h.x,0,h.y,0)
else
c.red.Parent = c.frame1
c.red = c.frame1.Red
c.red.Position = curRedPos
end
else
timer += dt
end
end)
Hey, I got notified about this because you mentioned my post, you could try using this:
-- From the post I found my solution in
local gui = ... -- some GUI
local desiredAbsolutePosition = -- some Vector2
local relativePosition = desiredAbsolutePosition - gui.Parent.AbsolutePosition
gui.Position = UDim2.fromOffset(relativePosition.X, relativePosition.Y)
Then change UDim2.fromOffset to UDim2.fromScale.
If that doesn’t work you could use a function like this to change the offset to scale:
local function OffsetToScale(Offset)
local ViewPortSize = workspace.Camera.ViewportSize
return ({Offset[1] / ViewPortSize.X, Offset[2] / ViewPortSize.Y})
end
about the local relativePosition = desiredAbsolutePosition - gui.Parent.AbsolutePosition that does not work, the red frame basically becomes slower depends on the parent size. Plus using the / screengui.AbsoluteSize it does not work it exactly wanted. Try that in new project, add a screengui and red frame inside a small frame, try making the red frame scale position be 1