Problem with pseudo-classes

UDim2.lua:23:attempt to index field "X" (a nil value) stack traceback: UDim2.lua:23: in function "GetAbsolutePosition" main.lua:13: in function "CreateImageRect" main.lua:22: in main chunk

What am I doing wrong?

UuwFhuP.png

Source of Vector2.lua -> https://gist.github.com/Elmuti/cd218733c3bb0c1b19c00a83414a20e7

Source of UDim.lua -> https://gist.github.com/Elmuti/d17beaba884ffb4bc1d51f67bcd40e7f

Source of UDim2.lua -> https://gist.github.com/Elmuti/a093798df30286b4378d5d80491bb6ce

Source of main.lua -> https://gist.github.com/Elmuti/2950eaaebca8701121e71667d4a89ef4

I don’t see where you’re creating a member named X and a member named Y. Both of those appear to be tables that are going to hold values like “offset”.

Side note, you don’t need to require “display”. It’s always there for you.

Rob

What’s your usage that’s having this error?

Loaded up the code from your Gist.

local test = UDim2.new(0.5,0,0.5,0) print(require("json").encode(test)) print(test:GetAbsoluteSize())

This gives the following:

{"Y":{"Offset":0,"Type":"UDim","Scale":0.5},"X":{"Offset":0,"Type":"UDim","Scale":0.5},"Type":"UDim2"} 540, 960

So your object properties appear to be set.

I assume the error comes from whatever you’re passing into your position method as an argument.

I don’t see where you’re creating a member named X and a member named Y. Both of those appear to be tables that are going to hold values like “offset”.

Side note, you don’t need to require “display”. It’s always there for you.

Rob

What’s your usage that’s having this error?

Loaded up the code from your Gist.

local test = UDim2.new(0.5,0,0.5,0) print(require("json").encode(test)) print(test:GetAbsoluteSize())

This gives the following:

{"Y":{"Offset":0,"Type":"UDim","Scale":0.5},"X":{"Offset":0,"Type":"UDim","Scale":0.5},"Type":"UDim2"} 540, 960

So your object properties appear to be set.

I assume the error comes from whatever you’re passing into your position method as an argument.