#Attempt to index nil with Find First Child (Line 27)

6 messages · Page 1 of 1 (latest)

sly musk
#

`for i, v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.Value)
if NewItem ~= nil then
items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillboardGui.Frame.Visible = false
end

if v:FindFirstChild("Dependancy")then
    coroutine.resume(coroutine.create(function()
        v.ButtonPart.Transparency = 1
        v.ButtonPart.CanCollide = false
        v.ButtonPart.BillboardGui.Frame.Visible = false
        if BoughtItems:WaitForChild(v.Dependency.Value, 100000) then
            v.ButtonPart.Transparency = 0
            v.ButtonPart.CanCollide = false
            v.ButtonPart.BillboardGui.Frame.Visible = true
        end
    end))
end

v.ButtonPart.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
        if Values.OwnerValue.Value == Player then
            if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
                if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
                    Player.leaderstats.Cash.Value -= v.Price.Value
                    items[v.Item.Value].Parent = BoughtItems
                    v:Destroy()
                end
            end
        end
    end
end)

end
`

Line 27 is the second line

plush osprey
#

it means whatever youre using FindFirstChild() on is nil

#

for example if i did object:FindFirstChild("item")

#

and i get your error

#

it means object does not exist

#

so it cant find item because there is no object