Profile Service with saving Tables

Hey Devs!

I am trying to save players Data with ProfileService, and I’m trying to save the players inventory (table.) Is there any tutorials or topics that help what I am looking for? Or is there other stuff to do?

Let me know! Thanks!

Sincerely,

papahetfan

its simple
first you have to set
local PlayerData = {
PlayerData = {
Coins = 0;
Level = 1;
[“OwnedGamePass”] = {
[“VIP”] = false;
};
};
… ← etc
}
GameHandler.PlayersProfile[plr] = PlayerData

when player leave Gamehandler.PlayersProfile[plr]:Release()

He asking for saving actual player’s inventory, currently all i and he knows that you can only save values such as money and etc (wrong reply, i was trying to reply to the guy who posted first)

I think like this?

if player and player.Backpack and #player.Backpack:GetChildren() > 0 then
for i,v in pairs(player.Backpack:GetChildren()) do
if v and player and self:GetPlayerData(player)["PlayerData"]["Inventory"][tostring(v.Name)] ~= nil then
GameHandler.PlayersProfile[player].Profile.Data["PlayerData"]["Inventory"][tostring(v.Name)] = {OwnedItem = true, Count = tonumber(self:GetPlayerData(player)["PlayerData"]["Inventory"][tostring(v.Name)]["Count"])+1}
else
GameHandler.PlayersProfile[player].Profile.Data["PlayerData"]["Inventory"][tostring(v.Name)] = {OwnedItem = true, Count = 1}
end
end
end
1 Like

Save the players invetory’s items into strings with counts for the item counts. Then when the player joins loop on the strings and clone them in server storage to the player. The items in server storage must have the same name as the string. To clone with amount of counts do this:

for i = 1, count, 1 do
  local test = ItemsInServerStorage:WaitForChild(itemString):Clone()
  test.Parent = playerInventory
end
2 Likes

I have already made a player inventory with profile service it is very easy and profile service is more scalable than you think

Yea thank you guys, i was trying to find out how would i go about saving player’s inventory like a month ago lol

1 Like

his asking how to save the player inventory into table with ProfileService as DataStore, not cloning tools into player inventory

Basically the script he sent gives the amount of items based on saved values in the table

1 Like

That’s how to save it in a table. Profile Service is a nested table.

table.insert(profile.Data.PlayerInventory, itemName)

This will add the itemName into a table. You can either do this method to add items, or you can use a count method so you check if there is already an item in there with the same name and then add a count.
Here is the table layout for this:

profile{
 -data{
  - PlayerInventory{
   -sword{
     2 -- count
   }
   -axe{
    4 -- count
   }
  } 
 }
}

Then you can clone with my above example

Hope this helps you understand!

using table.insert
the table result will be
[“Inventory”] {
[1] = “Sword”,
[2] = “Potion”,
}

Oh yeah sorry you should do this:

profile.Data.PlayerInventory[ItemName] = count

this may work but you may have to improve more to this code if needed

You will not need to change anything to make this work.

1 Like

That tutorials you sent do not relate to the problem the OP is having at all, though. They’re asking how to save tables/the player’s inventory using ProfileService, not how to use ProfileService on itself.