|
| 17 Feb 2016 11:27 PM |
I've been thinking, is it possible to save the tools in a players backpack so when they join a new server the same tools are there? Like data save leader stats, except the backpack saves.
Is it possible? |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 11:28 PM |
Just get string value's to represent everything in the backpack. Then put the string values into a table then save it to a datastore.
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 Feb 2016 11:30 PM |
You could use the SaveInstance method (http://wiki.roblox.com/index.php?title=Data_Persistence_Complete_Guide#Save_Instance) but DataPersistence is (or from what I've hear) 'outdated'.
In your case, it would be much more ideal to save the name of the tools they have and when they join, have it cloned into their Backpack/StarterGear |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 11:35 PM |
| Hmm, save the name... How exactly would I do that? |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 11:38 PM |
local ds = game:GetService("DataStoreService"):GetDataStore("Data") --Get a datastore
game.Players.PlayerRemoving:connect(function(player) local key = "key_"..player.userId local async = ds:SetAsync(key, "Name") end)
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 Feb 2016 11:43 PM |
http://wiki.roblox.com/index.php?title=Data_store
The DataStoreService lets you save certain types of values in key-value pairs in DataStores. You can save a table of all the names of the tools using the SetAsync method.
Here's a tiny example: local dataStore = game:GetService("DataStoreService"):GetDataStore("ToolSaves");
local function saveTools(plr) local tools = plr.Backpack:GetChildren(); for key = 1, #tools do tools[key] = tools[key].Name; end dataStore:SetAsync("user_" .. plr.userId, tools); end
local function loadTools(plr) local tools = dataStore:GetAsync("user_" .. plr.userId); if tools and type(tools) == "table" and #tools > 0 then for key = 1, #tools do game.ReplicatedStorage.Tools[tools[key]]:clone().Parent = plr.Backpack; end end end
This might not work out of the box, but the concept is there. |
|
|
| Report Abuse |
|
|