I am creating an inventory system where when a player is loaded in, a folder is put into the player and parts/items will be placed in that folder that will later be added to the gui. Right now i have a simple remote event thats sending a clone of an object to this script and i want to know how to add the item into the inventory folder of the player
local dss = game:GetService("DataStoreService") local ds = dss:GetDataStore("InventoryData") game.Players.PlayerAdded:Connect(function(p) local invFolder = Instance.new("Folder", p) invFolder.Name = "Inventory" end) game.ReplicatedStorage.Folder.RemoteEvent.OnServerEvent:Connect(function(plr, item) -- put this item into plr inv folder end)
This problem is all about storing values and reading them and dont make the client sending give item events let the server deal with giving stuff to your inventory personally I like storing items inside of dictionaries that consist of the player name and the item name bellow like
Table.insert(table[playerName][“inventory”],ItemName)
To retrieve your item you can just
Table[plrName][“inventory”][selectedItemName]
And now for the cloning you can have a module script dedicated for storing item stats
Local tableofitems = require(pathtomodule) tableofitems[Table[plrName][“inventory”][selectedItemName]]:Clone() now you have the item
In the module simple not complex
Return table.freeze({[“item”] = item directory})
Note: I wrote this on mobile so I can’t test it