Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 01:16 AM |
I have searched all over youtube, the Roblox Wiki and previous threads on the forum for an answer to the question, how can I use DataStores to save and load my players weapons and tools.
It seriously angers me that there are no tutorials that are fully functioning and up to date about DataStores and how they can be used to save and load tools. You can see tools being saved and loaded normally in Apocalypse Rising (http://www.roblox.com/games/1600503/Apocalypse-Rising) but how did they conjure up a script to save and load those tools? Why are questions like these not being answered by Developers who use DataStores for their games, Scripters who know very well how these work and even workers over at the ROBLOX office that used to post very helpful tutorials on their youtube channel.
Tutorials for DataStores can be found all over the place. But there are no tutorials that tell you how to save and load tools.
If you have the answer, please just tell all of us who want to know how. |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2016 01:21 AM |
Either you lack knowledge of coding in Lua so you automatically find it difficult or you just didn't look hard enough. I learnt the basics of datastores here:
https://www.youtube.com/watch?v=VXcbZ2kurvk
|
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 01:23 AM |
| I have already watched this, and yes I don't know EVERYTHING but I know enough to make some cool games. However DataStores are just not up my alley of knowledge. |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2016 01:24 AM |
Never done this before but here's what I would try first, assuming you know Lua.
I would use the datastores to store the tool's ID, or some number that's associated with it, then when a player joins a server I'd have a script check his/her datastores for a tool number and then give it to them from some other folder or even import it.
Just my 2 cents. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 01:39 AM |
| Ok lets say that in line 24 of that dudes script, how would I go about checking every players inventory every secound and saving it to the datastore? Because I dont want to load up a value. I want to load up the tool saved in ServerStorage and hand it to them when they join. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 01:41 AM |
| Would I save it as a string that matches the players tools? |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2016 01:44 AM |
| You could use SaveInstance to save the actual tool, but this isn't efficient and it might cause problems. So saving a string or an ID, and matching it is the best way. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 01:47 AM |
Yeah because I know you cant save instances but you could save Values and Strings, but how do I go about finding the players tools? and then how do I save those tools as the string? Saving tools really should not be this hard. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
|
| 18 Feb 2016 02:17 AM |
You get the string by simply using the name of the tool, but if there are multiple tools you will want to create a table.
tab = {} p=player.Backpack:GetChildren() for i=1,#p do table.insert(tab,p[i].Name) --I'm assuming each tool has a unique name end
DataStore:SetAsync("weapons", tab) --weapons is the name of the key, and tab is a table of all the names of the weapons a player has in his Backpack |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
|
| 18 Feb 2016 02:33 AM |
| That was just psuedo code, note that in your actual game the key name will have to be unique to the player... I just used "weapon" as an example. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 02:43 AM |
And how do I load these and give them to my player?
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2016 03:02 AM |
| Honestly I would just write out the script for you, but I think it would be best if you gained the experience from figuring it out. A lot of things can go wrong with DataStores, and you can end up ruining everyone's data which is why I suggest mastering the basics first. I recommend to start by figuring out how to use a table to give tools to players. |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 06:44 PM |
I was up all night last night trying to get something like this to work, but whatever I tried would result in errors.
Does anyone have a Tool DataStore Script that I can look through to see what in the world I am doing wrong? |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 18 Feb 2016 11:29 PM |
| You could probably just update a DataStore whenever a user gains or loses a tool (you should probably not allow dropping as they could then attempt to overload the DataStore request limits). Just store a string that uses commas to separate between tool names, then update the string whenever they gain or lose a tool as mentioned in the last sentence. When the player joins, just takes the string and look for all the tool names separated by commas before giving the tools to them. |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 18 Feb 2016 11:44 PM |
I finally got my tools to save with datastores :D
|
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 18 Feb 2016 11:45 PM |
Use datastore with a bool value.
|
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
| |
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 18 Feb 2016 11:47 PM |
| @Mapyo literally just told you how |
|
|
| Report Abuse |
|
|
Mapyo
|
  |
| Joined: 04 Jun 2009 |
| Total Posts: 475 |
|
|
| 18 Feb 2016 11:49 PM |
I cant get it to work AT ALL.
|
|
|
| Report Abuse |
|
|