Dragger Function Using Scale Not Offset?

Well the position will have to be an offset because Mouse.X and Mouse.Y is an offset so it doesn’t make any sense to convert it to scale.

So I’m pretty sure it’s the size you want to be scale (that way it’ll be the same size on resolutions)

You can convert offset to scale with

offset / viewportSize -- viewportsize or parent.AbsoluteSize

and scale to offset with

ViewportSize * scale -- viewportSize or parent.AbsoluteSize

Oh, I see. You want the frame to snap to the mouse position when you drag it? If that’s the case, then this (might) work:

 local X,Y = Mouse.X, Mouse.Y
 local sizeX, sizeY = CurrentCam.ViewportSize.X, CurrentCam.ViewportSize.Y

local posX, posY = X/sizeX,Y/sizeY

Frame.Position = UDim2.fromScale(posX,posY)
— drag

Why cant I just convert the Mouse position to a scale? Aka what my script does.

That is what my script is doing just using UDim.new instead of from scale

Oh I see, sorry about that. I’ve gotta sleep, good luck though!

You can but there is not point and it’s a waste, because Mouse.X and Mouse.Y are offset from the screen resolution and you want it to follow the mouse no matter the screen resolution.

I’m pretty sure (not 100% sure) what you want is the UI size to be scale, that way it’s the same size on a bigger or smaller screen resolution.

I am making a UI library and every object that I create in the UI library uses Scale not offset so this would break that. The size of the Frame is not what I am focused on it is the Dragger not working using scale

I don’t think it will break the library

what I do is when the player is dragging

run.RenderStepped:Connect(function()
    UI.Position = UDim2.new(0,Mouse.X,0,Mouse.Y) -- this way it'll drag properly no matter the resolution and no matter the parent
end

-- when the player "places" it parent it and convert it to scale

I need the centre of the frame on the mouse

Okay that will work that’s not a problem, just set the frame’s Anchor Point to 0.5,0.5

Changing the anchor point will mess up the Frame creator in my Library as the normal anchor point is 0, 0 so it will mess up the positioning and the equal gap that I have put in

So what you want to do, is have the mouse in the center of the UI with the UI anchor point at 0,0. For that you would have to apply offset

run.RenderStepped:Connect(function()
    UI.Position = UDim2.new(0,Mouse.X - (UI.Size.X.Offset / 2), Mouse.Y - (UI.Size.Y.Offset / 2)
    -- if you don't have UI.Size in offset you'll have to convert it

    -- p.s. not 100% sure if this will work but I think it will, may as well try
end)

I am using Scale for size not offset as I said “every object that I create in the UI library uses Scale”

you are able to change the properties after you create them though? Plus you aren’t changing it from scale to offset you are just getting the offset so you can use it to position it properly

Look this is the way I know how to do it

Good Luck on figuring this out

This could help you:

When it starts to move, add a snippet that resizes to equal AbsoluteSize and moves it to the ScreenGui.

You could use Scale if the object is not a descendant of a Frame or something like that