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

Getting error. Help? :|

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)

1 comment

0

Try getting in the habit of good formatting.. Use Tab. Can you please edit and show the error?

1 answer

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)

3 comments

0

Aye, printing is the best! Also, he is not missing quotes. You do not index variables using quotes.

0

you do with the method FindFirstChild...

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