How to make a gui point towards a udim2 roblox

I want to be able to make a gui point towards a udim2 position,
but all the info on how to rotate a gui towards a point has been using vector2

then I tried to find how to convert Udim2 into a vector2 but the way that worked was by multplying the screen size (or gui parent size) by the scale and doin nothing with the offset but that cant work becuse I`m doing this math on the server where the screen size is always 1,1

Any help is appriciated!

2 Likes

UDim2 position is 2 dimensional. If you need to change the orientation of GuiObject’s then simply modify the “Rotation” property of the desired Gui elements. It works in degrees, so 0/360 for default, 180 for upside down etc.

yea I get that but how do I do that with code? like make a gui point towards a udim2 position

local textBox = script.Parent
textBox.Rotation = 0 --change this number

Something like the above would achieve that.

ok I think you missundertsood me
I want to know how to make a gui rotated towards a udim2 position
not how to change a guis rotation

Couldn’t you use .AbsolutePosition and .AbsoluteSize? If not I think you could something like this:

local function toVector2(udim2, parentAbsSize)
	local x = udim2.X.Scale*parentAbsSize.X + udim2.X.Offset
	local y = udim2.Y.Scale*parentAbsSize.Y + udim2.Y.Offset
	return Vector2.new(x, y)
end

to account for both the scale and the offset.

2 Likes