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

how to put a part into the players inventory?

Asked by 2 years ago

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)
0
the item parameter is a clone of an object, not sure it that matters, i have tried different ways but it wont go into the folder. Silvanatri 24 — 2y

1 answer

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

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

0
I thought about doing that but i am copying devking tutorial form youtube and he made what im using but he skipped over the part of putting a new object into the inv/foler and just added the values as if the player already had the item in the inventory Silvanatri 24 — 2y
Ad

Answer this question