Let the Inventory save when I leave the game?

Hi everyon I hope someone can help me this time so I’m currently working on an Inventory System and right now I want that if I leave a game or lose a Tool or idk a Tool gets added and I leave the Inventory should look the same I got tips on how to do this with steps who told me this
You would have to code for that.

That’s what I said but I got 2 Scripts here I used to use for my inventory System(I just need a code pls don’t tell me to go on an Assistant page or just paste me a Topic with Data Store Help for beginners I need the exact code so I can understand what is happening I’m not a pro scripter this all may sound a bit mean from me but…


local inventoryEvent = game.ReplicatedStorage.Remotes.InventoryEvent


local inventory = player:WaitForChild("Inventory")

local inventoryFrame = player.PlayerGui:WaitForChild("InventoryGui").InventoryFrame.ItemsFrame:GetChildren()

	inventoryEvent:FireClient(player, Item.Name, true)

inventoryEvent.OnServerEvent:Connect(function(player, ItemName, Value, button)

 if Value == false then
		local SelectedItem = player.Inventory:FindFirstChild(ItemName)
		local backpack = player.Backpack:GetChildren()
		local stuff = player.Character:GetChildren()
		if #backpack == 0 and not player.Character:FindFirstChildWhichIsA("Tool") then
			button.Text = "Unequip"
			button.BackgroundColor3 = Color3.new(255,0,0)
			SelectedItem:Clone().Parent = player.Backpack
			for i,v in ipairs(backpack) do
				button.Text = "Equip"
				button.BackgroundColor3 = Color3.new(0,255,0)
			for i, v in ipairs(stuff) do
				if v:IsA("Tool") then
					button.Text = "Equip"
					button.BackgroundColor3 = Color3.new(0,255,0)


local InventoryEvent = game.ReplicatedStorage.Remotes.InventoryEvent
local itemFrame = script.Parent:FindFirstChild(“ItemsFrame”)

InventoryEvent.OnClientEvent:Connect(function(ItemName, Value)
if Value == true then

local ItemButton = script.Parent.ItemsFrame.ItemButton:Clone()
ItemButton.Visible = true
ItemButton.Name = ItemName
ItemButton.Text = ItemName
ItemButton.Parent = itemFrame

local equipButton = script.Parent.EquipFrame[“EquipButton”]

script.Parent.EquipFrame.Title.Text = ItemName
script.Parent.EquipFrame.Title.Visible = true
equipButton.Visible = true

Create a table of everything the player has in the inventory then use DataStores to save that table. Then when a player joins, use their data stored in their DataStore to load their items into their inventory.

I recommend you use HttpService and DataStore.

HttpService is great for security and ensuring that each item is unique so it cannot be stolen.
DataStore is great for saving things such as strings and tables.

I also recommend you use pcall and BindToClose just in case something bad happens to the data.

how do I do like this table is like hard to do or is it a code I might be the biggest script noob sry

There’s plenty of tutorials on the forum, as well as on youtube.

Here’s a simple youtube tutorial that explains step by step how to do this.

1 Like

dude this was the exact tutorial I needed I thought this was gonna be a weird goofy vid again but no!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.