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

Problem with inventory system (Can only pick up 1 item) Anyone know why?

Hello, so I am trying to create an inventory system for my game and I have ran into a little problem. So when I only have 1 item in the game to pickup it works absolutely fine but when I have 2 it only picks up one and I cannot pick up the other. Here is a gif: https://gyazo.com/48d1bdf2f8d6a757d415e90781bb0c64

How the system works is: So basically when the part is clicked on a script detects it uses a BindableFunction to get the items name, Parent and so on. When it gets this information it will then make a clone of the part and place it in the users inventory which is inside of ReplicatedStorage. When the item is inside replicated storage and has finished cloning it will then send a remoteEvent using "FireClient" to the script inside StarterCharacterScripts and inside that script is where it adds it to the inventory. Here is a picture of all of the scripts: http://prntscr.com/mq1mp4

and inside of each script:

AddItemToGUI: http://prntscr.com/mq1n4c

AddItemToInventory: http://prntscr.com/mq1ni5

GiveItemInfo: http://prntscr.com/mq1npd

1 answer

Alright, so I read your scripts and here's what is happening. When you use Invoke, the parts are being returned yes but it's only referencing one part.

So to solve this I recommend you do this for your AddItemToInventory script.

local Items = {}
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("ItemInfo") and v:FindFirstChild("ClickDetector") then
table.insert(Items, v)
end
end
for i,v in pairs(Items) do
v.ClickDetector.MouseClick:Connect(function(Player)
v.Transparency = 1
local Clone = v:Clone()
Clone.Parent = game.ReplicatedStorage["Asiimoz_Inventory"]
game.Workspace.RemoteEvent:FireClient(Player)
end)
end

So I recommend you remove the GiveItemInfo scripts in each of the parts and make a Folder called ItemInfo so you can story the properties in there.

1 comment

0

Where would I put this script and folder and when you say put the items properties in the folder do you just mean have the item cloned in that folder? I need you to be a bit more specific as I am a little new to scripting

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