#Need help with Inventory System i cant get the name or number of the items

1 messages · Page 1 of 1 (latest)

gleaming zodiac
#

Can someone help with this script I cant neither the number or name of an item on my inventory system

--Local Script
local Player = game:GetService("Players")
local RS = game:GetService('ReplicatedStorage')

local LocalPlayer = game.Players.LocalPlayer
local PlayerGUi = LocalPlayer.PlayerGui
local GUI = PlayerGUi:WaitForChild("Inventory")
local InvTemp = GUI.Inventory.ScrollingFrame.invtemp

local InvSroll = GUI.Inventory.ScrollingFrame

local itemsData = require(script.ModuleScript)
local getInventoryFunction = RS:WaitForChild("Remotes"):WaitForChild("getInventory")

local playerItems = getInventoryFunction:InvokeServer()

for itemName, itemData in pairs(itemsData) do
if itemData.Enabled == true then
local newItem = InvTemp:Clone()
newItem.Visible = false
newItem.Parent = InvSroll
newItem.Name = itemName
newItem.TextButton.Text = itemName.Name
newItem:AddTag(itemData.Class)
newItem.TextButton:AddTag("invItem")
end
end

if playerItems then
for itemName , itemData in pairs(playerItems) do
if itemsData[itemData] and itemsData[itemData].Enabled == true then
if itemData.Quantity > 0 then
local item = InvSroll:FindFirstChild(itemName)
item.Visible = true
item.TextButton.UseLabel.Text = 'x'.. itemData.Quantity
end

    end
end

end

--Server Script
local RS = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')

local getinventoryfucntion = RS.Remotes.getInventory

local PID = {}

game.Players.PlayerAdded:Connect(function(player)
PID[player.Name] = {
Wood = {Quantity = 5},
Nails = {Quantity = 2},
}
end)

getinventoryfucntion.OnServerInvoke = function(Player: Player)
local InventoryData = PID[Player.Name]
print(InventoryData)
return InventoryData
end

#

-- Module Script local ItemData = {}

Wood = {
    DisplayName = "Wood";
    Class = "Wood";
    Enabled = true
}

Planks = {
    DisplayName = "Planks";
    Class = "Wood";
    Enabled = true
}

Nails = {
    DisplayName = "Nails";
    Class = "Metal";
    Enabled = true
}

FlashLights = {
    DisplayName = "FlashLight";
    Class = "LightSource";
    Enabled = true
    
}

Vines = { 
    DisplayName = "Vines";
    Class = "Craftables";    
    Enabled = true
}

Batteries = {
    DisplayName = "Battery";
    Class = "Energy";
    Enabled = true
}

Rope = {
    DisplayName = "Rope";
    Class = "Craftable";        
    Enabled = true
}

return ItemData

tame solar
#

You just created multiple individual tables and none of em are associated with ItemData in any way

#

So the module script returns a empty table

supple leaf
tame solar
#

Not entirely. Í haven't seen the rest of the code yet

#

But yeah that is needed