generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Hmmmm...

Previous Thread :: Next Thread 
MisterPotater is not online. MisterPotater
Joined: 16 Jan 2013
Total Posts: 200
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
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
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 is not online. 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
MisterPotater is not online. MisterPotater
Joined: 16 Jan 2013
Total Posts: 200
17 Feb 2016 11:35 PM
Hmm, save the name... How exactly would I do that?
Report Abuse
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image