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

Trying to make an inventory script but this just went wrong... How do I fix?

Asked by 7 years ago
Edited 7 years ago
script.Parent.ClickDetector.MouseClick:connect(function(Player)
    local Inventory = Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory
    for i,v in next,Inventory do 
        if not v.Taken.Value == false then 
        v.ItemNumber.Value = script.Parent.ItemId.Value
    v.Image = script.Parent.PicId.Value
        end
    end

end)

error>>>

17:12:59.375 - Workspace.Book.Script:4: bad argument #1 to '(for generator)' (table expected, got Object)
17:12:59.376 - Stack Begin
17:12:59.377 - Script 'Workspace.Book.Script', Line 4
17:12:59.381 - Stack End

0
for i, v in pairs loops require a table. While you are just requiring 1 thing. Just say local Inventory = Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory:GetChildren() DeveloperSolo 370 — 7y
0
@JhonTUnderwood It worked but it did it to all of them. I want it to do it to the first one that it finds thats false not all of them Stephenthefox 94 — 7y

Answer this question