Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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()
0
You need to include a description of what the script is supposed to be doing. NotsoPenguin 705 — 9y
0
line 15 will remove the hat from the player that is the part that is broken all other works fine Layfonex 0 — 9y
1
You are trying to call FindFirstChild on a table value(lo) NotsoPenguin 705 — 9y
1
You can only use FindFirstChild() on objects and such. Perci1 4988 — 9y
View all comments (8 more)
0
so how should i do this ? ive never had this problem before.. Layfonex 0 — 9y
1
^ Instead of that, he could just do gui.Parent.Parent.Character:FindFirstChild() and just never call GetChildren. Perci1 4988 — 9y
0
still nil value Layfonex 0 — 9y
0
What did you change it to? Update your post? NotsoPenguin 705 — 9y
0
Are the children of 'removed' a TextLabel or something? M39a9am3R 3210 — 9y
0
its a textbutton Layfonex 0 — 9y
0
use should use the pairs. woodengop 1134 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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

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

Ad

Answer this question