So I need to convert Udim2 to Vector2 and I stumbled across this function on the roblox forums. The only problem is I keep on getting this error : attempt to index field 'X' (a number value). So I decided to break the math up into separate lines to see which line is causing the error. It says it is happening on line 6. Here is the function, any help is greatly appreciated!
local function toV2(ud2)
local scr = c.ViewportSize
local x = math.floor((ud2.X.Scale*
scr.X)
+0.5) + ud2.X.Offset
local y = math.floor((ud2.Y.Scale*
scr.Y)
+0.5) + ud2.Y.Offset
return Vector2.new(x,y)
end
