|
| 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 |
|
|
|
| 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 |
|
|
|
| 25 Nov 2015 02:11 AM |
| i get the feeling that you're not a very likeable person |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 19 Nov 2015 |
| Total Posts: 217 |
|
| |
|
|
| 25 Nov 2015 04:31 AM |
| Why did you help them? *facepalm* |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Nov 2015 10:14 PM |
fun4nerd, that is complete bullcrap.
http://www.roblox.com/siggy-item?id=322100454 |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Nov 2015 10:37 PM |
'wait(5)' PSHHHH.
http://www.roblox.com/siggy-item?id=323595991 |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 25 Nov 2015 11:17 PM |
Grammar thug, I'm the police.
http://www.roblox.com/siggy-item?id=323595991 |
|
|
| Report Abuse |
|
|