Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 21 Apr 2016 04:51 PM |
Everything you need to know:
Script (inside ServerScriptService):
local key = "dataStorageREDUX" local DataStore = game:GetService("DataStoreService"):GetDataStore(key) game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("IntValue", game.ServerScriptService.Stats) stats.Name = player.Name.."Stats" local pic = Instance.new("IntValue", stats) pic.Name = "pic" pic.Value = 429384 local characterOne = Instance.new("BoolValue", stats) characterOne.Name = "characterOne" characterOne.Value = false local classOne = Instance.new("IntValue", characterOne) classOne.Name = "classOne" classOne.Value = 0 local genderOne = Instance.new("IntValue", characterOne) genderOne.Name = "genderOne" genderOne.Value = 0 local levelOne = Instance.new("IntValue", characterOne) levelOne.Name = "levelOne" levelOne.Value = 1 local savedValues = DataStore:GetAsync(key..player.UserId) if savedValues then pic.Value = savedValues[1] characterOne.Value = savedValues[2] classOne.Value = savedValues[3] genderOne.Value = savedValues[4] levelOne.Value = savedValues[5] else local valuesToSave = {pic.Value, characterOne.Value, classOne.Value, genderOne.Value, levelOne.Value} DataStore:SetAsync(key..player.UserId, valuesToSave) end end) local DataStore = game:GetService("DataStoreService"):GetDataStore("dataStorageREDUX") game.Players.PlayerRemoving:connect(function(player) local valuesToSave = {game.ServerScriptService.Stats[player.Name.."Stats"].pic.Value, game.ServerScriptService.Stats[player.Name.."Stats"].characterOne.Value, game.ServerScriptService.Stats[player.Name.."Stats"].classOne.Value, game.ServerScriptService.Stats[player.Name.."Stats"].genderOne.Value, game.ServerScriptService.Stats[player.Name.."Stats"].levelOne.Value} DataStore:SetAsync(key..player.UserId, valuesToSave) local save_table = {} for number,data in pairs(valuesToSave) do table.insert(save_table,{data.Name,data.Value}) end key:UpdateAsync(key..player.UserId, function() return save_table end) end)
______________________________________________________________________________________
This is how I am accessing the values: game.ServerScriptService[stats].pic.Value
______________________________________________________________________________________
Error Message:
17:51:16.420 - Stats is not a valid member of ServerScriptService 17:51:16.421 - Script 'ServerScriptService.dataStorage', Line 6 17:51:16.421 - Stack End Animator Gui: Loaded succesfully 17:51:17.360 - Player1Stats is not a valid member of ServerScriptService 17:51:17.360 - Script 'Players.Player1.PlayerGui.Noted.landing.verify', Line 6 17:51:17.361 - Stack End 17:51:17.361 - Player1Stats is not a valid member of ServerScriptService 17:51:17.365 - Script 'Players.Player1.PlayerGui.Noted.landing.account.nc1.LocalScript', Line 7 17:51:17.365 - Stack End 17:51:17.366 - Player1Stats is not a valid member of ServerScriptService 17:51:17.366 - Script 'Players.Player1.PlayerGui.Noted.landing.account.char1.char', Line 6 17:51:17.366 - Stack End
|
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 05:21 PM |
its because the datastore is stored under "game.ServerScriptStorage.Stats(playername)Stats, you are trying to check if the stats are in game.ServerScriptStorage
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 21 Apr 2016 05:56 PM |
| so how should I get the values from a script them? how do I direct it. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
|
| 21 Apr 2016 06:16 PM |
game.ServerScriptStorage.Stats[player.Name.."Stats"].pic.Value
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 21 Apr 2016 06:50 PM |
Didn't Work. I think the problem is this:
19:48:56.194 - Stats is not a valid member of ServerScriptService 19:48:56.194 - Script 'ServerScriptService.dataStorage', Line 6 19:48:56.195 - Stack End
|
|
|
| Report Abuse |
|
|
|
| 21 Apr 2016 06:52 PM |
this is kind of irrelevant but you should use a table/dictionary for saving
you won't go over the request limit with it and it's more efficient
#Code print("Add 13,000 posts") |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
|
| 22 Apr 2016 05:37 PM |
The only safe way you can guarantee your table gets saved properly is to convert it to JSON format before saving it.
game.HttpService:JSONEncode(save_table)
thats how ya do it. |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2016 05:38 PM |
whoever posted this, its your fault on your scripts, not my datastore script.
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 22 Apr 2016 06:38 PM |
| still cant call the saved values, soooo |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2016 06:53 PM |
are you trying to access serverscriptservice from a localscript
|
|
|
| Report Abuse |
|
|
|
| 22 Apr 2016 09:19 PM |
| if you are using a local script try: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial |
|
|
| Report Abuse |
|
|