Problem with saving tool inventory

I’ve made an obby and after finishing the obby you get a speed & gravity coil and I’m trying to make an inventory saving system but I’m having trouble making it work. It does not show any error, but it does not save it also. I’ve used this tutorial but idk what I’m doing wrong: How to save your players' inventory items - #2 by skarz19

I’ve put this script in ServerScriptService:

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ServerStorage = game:GetService("ServerStorage")

local player_data = DataStoreService:GetDataStore("player_data")

local tools = ServerStorage.Tools
local inventories = ServerStorage.Inventories

	local key = "client_" .. client.UserId
	local inventory = player_data:GetAsync(key) -- Not worrying about pcalls, do that yourself

	local inventory_folder ="Folder")
	inventory_folder.Name = client.Name
	inventory_folder.Parent = inventories
	for _, name in ipairs(inventory or { }) do
		local tool = tool[name]
		tool:Clone().Parent = client.Backpack -- For the player to use
		tool:Clone().Parent = inventory_folder -- For saving and loading

	local key = "client_" .. client.UserId
	local tools = { }
	local inventory_folder = inventories[client.Name]

	for _, item in ipairs(inventory_folder:GetChildren()) do
		table.insert(tools, item.Name)

	player_data:UpdateAsync(key, function(prev)
		return tools


I’ve also made “Inventory” and “Tools” folders in ServerStorage, and I did put the coil inside the “Tools” folder. But still does not work… Anyone willing to help?

Try putting a pcall in, or have another value for inventory if it isn’t true, because if the variable inventory is nil nothing will work, also any errors you get in the output?

Are you testing in studio? if so you have to enable access to services like datastore

Tht is because u never gave the player any tool. From another script parent the tools from ur Tools folder to ur players inventory. You have to use remoteevents 4 this.

Also, ur tutorial comes with explanation on how 2 do tht too.

If you’re testing this in Studio, make sure to also hook game:BindToClose. PlayerRemoving behaves strangely around YieldFunctions in Studio

And either way, you should be using BindToClose if Roblox (or you) unexpectedly shuts down your server.

Howtoroblox made a great tutorial on this. very easy and quick way to achieve this.

How To Make SAVING TOOLS | HowToRoblox - YouTube