|
| 10 Nov 2017 07:58 PM |
local datastore = game:GetService("DataStoreService"):GetDataStore("HamburgerMewMeow932239") game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("NumberValue") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local promotion = Instance.new("NumberValue") promotion.Name = "BlueCash" promotion.Parent = leaderstats local salary = Instance.new("NumberValue") salary.Name = "GreenCash" salary.Parent = leaderstats local cash = Instance.new("NumberValue") cash.Name = "Cash" cash.Parent = leaderstats local userid = plr.userId local hasdata = datastore:GetAsync("cash"..userid) if hasdata == false then cash.Value = 500 datastore:SetAsync("cash"..userid, {cash.Value}) else cash.Value = hasdata[1] end local hasdata2 = datastore:GetAsync("salary"..userid) if hasdata2 == false then salary.Value = 5 datastore:SetAsync("salary"..userid, {salary.Value}) else salary.Value = hasdata2[1] end local hasdata3 = datastore:GetAsync("promotion"..userid) if hasdata3 == false then promotion.Value = 0.05 datastore:SetAsync("promotion"..userid, {promotion.Value}) else salary.Value = hasdata3[1] end end)
game.Players.PlayerRemoving:Connect(function(plr) local userid = plr.userId local promotion = plr.leaderstats.BlueCash local cash = plr.leaderstats.Cash local salary = plr.leaderstats.GreenCash local promotable = {promotion.Value} local saltable = {salary.Value} local cashtable = {cash.Value} datastore:SetAsync("promotion"..userid, {promotion.Value}) datastore:SetAsync("salary"..userid, {salary.Value}) datastore:SetAsync("cash"..userid, {cash.Value}) end) |
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 10 Nov 2017 08:00 PM |
| You tell us, what are the errors? |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:02 PM |
Probally one mistake error in it Check Carefully.
|
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:06 PM |
| I rejoin my game, and I get 500 money, # ######### # ########## and nothing has saved |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:07 PM |
| You should really tell me how to fix this blob of code |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 10 Nov 2017 08:13 PM |
From the wiki: >Data is also saved as a string in data stores, regardless of its initial type.
Šçrätčh ïïś ƒö® łëvëł 17 äñöñ DÖŠ HTMŁ hæx0rs whö üsë ŚQŁ++ ïïńśpëçt ëłæmęñtïïñg |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 10 Nov 2017 08:14 PM |
Stop bumping and posting if you have no idea how it errors. If you aren't going to help us understand your issue, we're not even going to try.
You need to tell us three things. 1: What is this script supposed to do? 2: What is this script doing? 3: What are the errors in the output? / Where does it stop printing? |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2017 08:16 PM |
1: What is this script supposed to do? It's supposed to make values for currencies and load and save them. 2: What is this script doing? Making the currencies, but doing no loading. Green/blue cash just becomes 0, regular cash becomes 500. It's weird. 3: What are the errors in the output? / Where does it stop printing? No errors in the output, but i'll try prints. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 11 Nov 2017 06:35 AM |
| It's a ##### of clutter, you really shouldn't be storing things in this way. Also you setasync like a trillion times back to back- you should try to bundle those into a single setasync because, yes, there is a limit The key in the datastore should be the player.UserId (note UserId is caps, userId is deprecated), and its value should be a table containing all this data. Also instead of generating each leaderstat value object, you should just clone a folder containing all of them preset so you don't have to create each one |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 11 Nov 2017 06:39 AM |
It's a lot of clutter, you really shouldn't be storing things in this way. Also you setasync like a trillion times back to back- you should try to bundle those into a single setasync because, yes, there is a limit
The key in the datastore should be the player.UserId (note UserId is caps, userId is deprecated), and its value should be a table containing all this data.
Also instead of generating each leaderstat value object, you should just clone a folder containing all of them preset so you don't have to create each one
|
|
|
| Report Abuse |
|
|