Code that passes the table:
local inventory = script.Parent
local hotbar = inventory.Hotbar
local inventoryInfo = require(inventory.InventoryOptions)
local localPlayer = game.Players.LocalPlayer
local backPack = localPlayer:WaitForChild("Backpack")
function backpackLoop()
local slotAmount = inventoryInfo.getSlotAmount(localPlayer)
for i = 1, slotAmount do
local newSlot = inventoryInfo.createSlot(i)
inventoryInfo.formatSlot(newSlot, backPack[tonumber(i)].TextureId, backPack[tonumber(i)].Name)
newSlot.Parent = hotbar
end
end
localPlayer.CharacterAdded:Wait()
backpackLoop()
And the getSlotAmount()
and formatSlot
in the module:
invInfo.formatSlot = function(slot,image,name)
if slot then
if image then
slot:FindFirstChild("MainLabel").Image = image
else
if name then
slot:FindFirstChild("BackupLabel").Text = name
else
error("No Image or Name data found!")
end
end
else
error("No slot specified!")
end
end
invInfo.getSlotAmount = function(localPlayer)
if localPlayer then
return #localPlayer.Backpack:GetChildren()
else
error("No localPlayer found!")
end
end
The error is 1 is not a valid member of Backpack "Players.Vercte2.Backpack"
at Client - InventoryManager:14