Need help with error

Whenever I try to run this is just says

invalid argument #2 (UDim expected, got number)

image

while wait() do
	local x = script.Parent.Size.X.Offset
	local y = script.Parent.Size.Y.Offset
	
	if  x < 200 then
		script.Parent.Size = UDim2.new(script.Parent.Size.Y, script.Parent.Size.X + 1)
	else
		if y < 100 then
			script.Parent.Size = UDim2.new(script.Parent.Size.Y + 1, script.Parent.Size.X)
		end
	end
end
2 Likes

UDim2 should have 4 numbers, try setting it to:

UDim2.new(script.Parent.Size.Y, 0,script.Parent.Size.X + 1, 0)
and
UDim2.new(script.Parent.Size.Y +1, 0, script.Parent.Size.X, 0)

1 Like

Ok I changed it to this:

while wait() do
	local x = script.Parent.Size.X.Offset
	local y = script.Parent.Size.Y.Offset
	
	if  x < 200 then
		script.Parent.Size = UDim2.new(0, script.Parent.Size.Y, 0, script.Parent.Size.X + 1)
	else
		if y < 100 then
			script.Parent.Size = UDim2.new(0, script.Parent.Size.Y + 1, 0, script.Parent.Size.X)
		end
	end
end

But im getting the same error
(Im going for offset because scale just is just a mess with different screen sizes

Put the zero at the 2nd and 4th numbers, instead of 1st and 3rd.

Because the 1st and 3rd are scales, and the 2nd and 4th are pixels.

1 Like

Im going for offset because scale just is just a mess with different screen sizes (If you have 1280×720 screen and someone else has 1920×1080 it just messes up)

Plus I tried it and still the same error

Fixed it! I was looking at it because of UDim2 it had the three numbers and I forgot to put offset

(script.Parent.Size.X.Offset + 1)

( aren1toross solution also helped : D )

2 Likes