Hey @sjr04 - this is an awesome tutorial, but I did run into an issue:
In your tutorial you showed:
Players.PlayerAdded:Connect(function(client)
local key = "client_" .. client.UserId
local inventory = player_data:GetAsync(key) -- Not worrying about pcalls, do that yourself
local inventory_folder = Instance.new("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
end
end)
I’m not sure if you meant to display tool = tools[name]
instead of tool[name]
- but it was failing to fetch the tools. Which made sense on why I was confused for why tool wasn’t defined globally.
I then did:
local tool = tools[name]
- however it then was trying to fetch the baseballbat within the baseballbat, so I made the following adjustments:
Players.PlayerAdded:Connect(function(client)
local key = "client_" .. client.UserId
local inventory = player_data:GetAsync(key)
local inventory_folder = Instance.new("Folder")
inventory_folder.Name = client.Name
inventory_folder.Parent = inventories
print("defined all the stuff")
wait(10)
for _, name in ipairs(inventory or { }) do
print("started for loop")
wait(1)
print(tools[name])
tools[name]:Clone().Parent = client.Backpack
tools[name]:Clone().Parent = inventory_folder
end
end)
I added a wait(10)
seconds function because the script was processing everything faster then the server was loading in the serverstorage. Perhaps this is because I’m using an empty baseplate to use this tutorial in order to make a custom inventory system?
I hope this helps anybody that may have had similar issues with this tutorial. Again, awesome tutorial - it helped me a lot with understanding the mechanics of for loops with datastore’s, much appreciated! <3