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

Getting error. Help? :|

Asked by 8 years ago

Getting error. Anyone can help with that? Here a script

local object = game.ReplicatedStorage.Items

    script.Parent.Parent.Inventory.MouseButton1Down:connect(function(control)
         for i, child in pairs(object:GetChildren()) do
   for i, child1 in pairs(child:GetChildren())  do
    local itemid = child1:FindFirstChild("ItemId") --added quotes to name
if itemid then
    warn(itemid.Value)
end
end
end
    end)
0
Try getting in the habit of good formatting.. Use Tab. Can you please edit and show the error? TheDeadlyPanther 2460 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

I think your only problem is you are missing some quotes. If that still doesn't work, double-check to see if name actually exists. Consider printing out stuff like the child1 table. Printing out stuff is a great way to debug!

local open = true
local object = game.ReplicatedStorage.Items
local name = "ItemId"
script.Parent.Parent.Inventory.MouseButton1Down:connect(function(control)
    if open == true then
       open = false
        script.Parent.Parent.InventoryGui.Visible = true
        for i, child in pairs(object:GetChildren()) do
   for i, child1 in pairs(child:GetChildren())  do
    local child2 = child1:FindFirstChild("name") --added quotes to name
        warn(child2.Value)
    end
end
    else
        open = true
        script.Parent.Parent.InventoryGui.Visible = false
    end
end)

0
Aye, printing is the best! Also, he is not missing quotes. You do not index variables using quotes. TheDeadlyPanther 2460 — 8y
0
you do with the method FindFirstChild... dragonkeeper467 453 — 8y
Ad

Answer this question