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

attempt to call method 'FindFirstChild' (a nil value) ?

Output: Players.Player.PlayerGui.Catalog.LocalScript:15: attempt to call method 'FindFirstChild' (a nil value)

function UpdateItems()
    local x, y = 0, 0.2
removeOldOutOfTheWay(gui.Main.Items:GetChildren())
    local lo = gui.Parent.Parent.Character:GetChildren()
    for _, child in pairs(lo) do
	if child.className == "Hat" then
       local new = settings.Items:Clone()
        new.Position = UDim2.new(x, 0, y, 0)
        new.Text = child.Name
        x = x + 0.031
new.Parent = gui.Main.Items
local removed = gui.Main.Items:GetChildren()
	for i = 1,#removed do
		removed[i].MouseButton1Up:connect (function()
			lo:FindFirstChild(removed[i].Text):remove()
		end)
		end
      end
    end
end

local a = gui.Parent.Parent.Character
a.ChildAdded:connect( UpdateItems )
a.ChildRemoved:connect( UpdateItems )
UpdateItems()

12 comments

0

You need to include a description of what the script is supposed to be doing.

0

line 15 will remove the hat from the player that is the part that is broken all other works fine

1

You are trying to call FindFirstChild on a table value(lo)

1

You can only use FindFirstChild() on objects and such.

0

so how should i do this ? ive never had this problem before..

1

^ Instead of that, he could just do gui.Parent.Parent.Character:FindFirstChild() and just never call GetChildren.

0

still nil value

0

What did you change it to? Update your post?

0

Are the children of 'removed' a TextLabel or something?

0

its a textbutton

0

use should use the pairs.

1 answer

✓ Accepted answer

As explained in the comments, 'lo' is a table/list (you created it using :GetChildren).

Replace lo:FindFirstChild with gui.Parent.Parent.Character:FindFirstChild.

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