Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why am I getting attempt to index nil with 'Y'?

12:44:39.658 - ReplicatedStorage.listController:36: attempt to index nil with 'Y' 12:44:39.659 - Stack Begin 12:44:39.660 - Script 'ReplicatedStorage.listController', Line 36 - function dynamicTruncateCanvas 12:44:39.660 - Script 'ReplicatedStorage.notifController', Line 70 - function addNotifacation 12:44:39.660 - Script 'Players.benbebop.PlayerScripts.ErrorMessager', Line 17 12:44:39.660 - Stack End

listController

function list.dynamicTruncateCanvas(dir)
	local x = dir:GetChildren()
	local scale = 0
	local offset = 0
	for i = 1,#x do
		if x ~= nil and x.ClassName ~= "UIListLayout" then
			scale = scale + x.Size.Y.Scale
			offset = scale + x.Size.Y.Offset
		end
	end
	dir.CanvasSize = UDim2.new(0, 0, scale, offset)
end

Line 36 = Line 7

I don't see why it won't work, its gets as far as x.Size (Confirming this is getting the right objects) but for some reason fails on getting the Y attribute. Anyone know what is going on?

1 answer

✓ Accepted answer

Please dont edit the table. See the comments below!

function list.dynamicTruncateCanvas(dir)
    local x = dir:GetChildren()
    local scale = 0
    local offset = 0
    for i = 1,#x do
        local x = x[i] -- set it to the actual object
        if x ~= nil and x.ClassName ~= "UIListLayout" then
            scale = scale + x.Size.Y.Scale
            offset = scale + x.Size.Y.Offset
        end
    end
    dir.CanvasSize = UDim2.new(0, 0, scale, offset)
end

If this helps, please mark as a solution!

Metatable out!

1 comment

0

While this wouldn't have fixed it exactly, it did make me realise that I somehow forgot [i]. Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.