I'm trying to make a script that uses a script that saves the player's inventory if they leave the game. Here's what I have so far:
local ds = game:GetService("DataStoreService"):GetDataStore("tools") game.Players.PlayerAdded:connect(function(player) local key = "user_" .. player.userId ds:UpdateAsync(key, function(old) old = game.Players.LocalPlayer.Backpack:GetChildren() if old:IsA("Tool") then local new = old or nil local tool = old:Clone() tool.Parent = game.Players.LocalPlayer.Backpack return new end end) end)
I copied some of it from the wikia. I think I'm doing it all wrong. Please help!
I suggest looking over http://wiki.roblox.com/index.php?title=Data_store again and reading it properly. To do this I would make a table
with item names in it and then you use those to access ReplicatedStorage
and clone the tools into their Backpack
.