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: Datastore pissing me off.

Previous Thread :: Next Thread 
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 01:47 AM
This code hasn't changed from 2 years ago, it should work.

The errors:

18:46:22.842 - GetAsync is not a valid member of DataStoreService
18:46:22.843 - Script 'ServerScriptService.DataStore', Line 19
18:46:22.844 - Stack End
18:46:30.544 - SetAsync is not a valid member of DataStoreService
18:46:30.545 - Script 'ServerScriptService.DataStore', Line 33
18:46:30.545 - Stack End

The code:

local dataStore = game:GetService("DataStoreService")
local storedData = dataStore:GetDataStore('PlayerData')

game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local stata = Instance.new("IntValue")
stata.Name = "Wins"
stata.Parent = leaderstats

local statb = Instance.new("IntValue")
statb.Name = "Losses"
statb.Parent = leaderstats

local key = "user-" .. player.userId

local storeditems = dataStore:GetAsync(key)
if storeditems then
stata.Value = storeditems[1]
statb.Value = storeditems[2]
else
local items = {stata.Value}
dataStore:SetAsync(key, items)
end
end)

game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Wins.Value, player.leaderstats.Losses.Value,}
local key = "user - "..player.userId

dataStore:SetAsync(key, items)
end)

http://www.roblox.com/siggy-item?id=322100454
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 01:53 AM
Bumping the thread, as no one on this subforum seems to be helpful at all.

http://www.roblox.com/siggy-item?id=322100454
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
25 Nov 2015 02:11 AM
i get the feeling that you're not a very likeable person
Report Abuse
Hexworx is not online. Hexworx
Joined: 19 Nov 2015
Total Posts: 217
25 Nov 2015 02:43 AM
dataStore:GetAsync(Key)...

I'm pretty sure it should be storedData:GetAsync(Key)
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 02:48 AM
Bloody ought, I changed the variables wrong. Thanks by the way.

http://www.roblox.com/siggy-item?id=322100454
Report Abuse
Hexworx is not online. Hexworx
Joined: 19 Nov 2015
Total Posts: 217
25 Nov 2015 03:01 AM
No problem.
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
25 Nov 2015 04:31 AM
Why did you help them? *facepalm*
Report Abuse
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
25 Nov 2015 07:20 AM
Add this inside a separate script inside of workspace. This fixed my errors with my datastores.
NOTE: Keep in mind that datastores really only work when your playing the game inside of roblox player.

game.OnClose = function()
print 'Closing, waiting'
wait(5)
print 'Done'
end
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 10:14 PM
fun4nerd, that is complete bullcrap.

http://www.roblox.com/siggy-item?id=322100454
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
25 Nov 2015 10:36 PM
@Gull, nah, it may help. It allows you to save your data using Data Stores before your game closes.
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 10:37 PM
'wait(5)'
PSHHHH.

http://www.roblox.com/siggy-item?id=323595991
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
25 Nov 2015 10:50 PM
No, seriously, after the last player leaves, it gives the server five extra seconds to save data before it closes (Which will halt and kill all running scripts, whether they are saving or not)
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 10:55 PM
I don't care, what I currently have works, it has never broken.

http://www.roblox.com/siggy-item?id=323595991
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
25 Nov 2015 11:12 PM
Good for you! I am so happy that what you have works!

Not really. When you are impudent and insolent, you can't really expect people to care that much about you, can you? If you do, then you're self-deceived fool. What goes around comes around.

"Why did you help them? *facepalm*"
"i get the feeling that you're not a very likeable person"
Notice that nobody on the thread wants to help impudent egocentric twerps.

I only helped to defend some people who you were arrogantly and ungratefully insulting and ridiculing.
You can go back to making a game, I don't expecting you to display gratitude towards anyone here.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
25 Nov 2015 11:14 PM
"I don't expecting you to display gratitude towards anyone here."
Oh, my mistake. You actually said thank you earlier. That doesn't exactly say "Sincere gratitude" like it does "formality" though.
Report Abuse
GullibleChapV2 is not online. GullibleChapV2
Joined: 21 Oct 2015
Total Posts: 5680
25 Nov 2015 11:17 PM
Grammar thug, I'm the police.

http://www.roblox.com/siggy-item?id=323595991
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