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
 

Re: Something in my datastore is not working.

Previous Thread :: Next Thread 
Fangous is not online. 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
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
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 is not online. 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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
21 Apr 2016 06:15 PM
@iJacobness
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
21 Apr 2016 06:16 PM
game.ServerScriptStorage.Stats[player.Name.."Stats"].pic.Value



r+://393244197r+://393244224r+://393244262
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
21 Apr 2016 06:17 PM
ill try it after dinner
<3
Report Abuse
Fangous is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
22 Apr 2016 03:41 PM
still need halp
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
22 Apr 2016 05:35 PM
halp
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
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
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
22 Apr 2016 06:38 PM
still cant call the saved values, soooo
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
22 Apr 2016 06:53 PM
are you trying to access serverscriptservice from a localscript
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
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
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