Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a module or something that converts offsets to scale for GUIs automatically?

Asked by 6 years ago
Edited 6 years ago

I've heard of UIScale but its description on the Wiki is very vague. It doesn't say it will convert offsets to scale.

Would anyone know of a module/library that does something like this? How would you convert position to scale?

child.Position = UDim2.new(child.AbsolutePosition.X/child.Parent.AbsolutePosition.X,0,
child.AbsolutePosition.Y/child.Parent.AbsolutePosition.Y,0)

Is pretty wrong for what I'm trying to do. If I do it that way, it will not scale position properly for some reason.

Any module(s), etc?

2 answers

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

You can try absolute position divided by the screen resolution, if that's what you mean.

Would this work?

function OffsetToScale(gui)
    local mouse = game.Players.LocalPlayer:GetMouse()
    local x,y = mouse.ViewSizeX,mouse.ViewSizeY
    gui.Position = UDim2.new(gui.AbsolutePositionX/x,0,gui.AbsolutePositionY/y,0)
end

OffsetToScale(frame)
Ad
Log in to vote
0
Answered by
E_Esty 5
4 years ago
Edited 4 years ago

I have a line of code that can convert any position to scale

--For X
positionx / camera.ViewportSize.X

--For Y
positiony / (camera.ViewportSize.Y - 36)

For Y you would have to subtract it by roblox's top bar height else it will be wrong.

Answer this question