Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My datasave doesn't save at all? [closed]

Asked by 6 years ago

Hello, a few weeks ago I watched a tutorial on DataSaving from AlvinBlox, mainly because I was a little confuzzled with it. I'm trying to save a number value (I believe it's called integers) via a location in the player's gui. Here's my code:

01local DSService = game:GetService('DataStoreService'):GetDataStore('XIPHER_921838582315538283812581238529158283')
02game.Players.PlayerAdded:connect(function(plr)
03 -- Define variables
04 local uniquekey = 'id-'..plr.userId
05 local savevalue =  plr.PlayerGui:WaitForChild("Cash").CashFrame.MoneyHolder.Money.MoneyHolder
06 -- GetAsync
07 local GetSaved = DSService:GetAsync(uniquekey)
08 if GetSaved then
09  savevalue.Value = GetSaved[1]
10 else
11  local NumbersForSaving = {savevalue.Value}
12  DSService:SetAsync(uniquekey, NumbersForSaving)
13 end
14end)
15 
View all 22 lines...

As you can see, I'm trying to save a value in a place in the player's gui. The script is a normal script, not a localscript and is in ServerScriptStorage. If anyone can help me whether if it should be in a different location, if it should be a localscript instead, or generally help me. Super appreciated!

P.S I tried earlier with studio and it does load a integer I saved a few minutes ago when I used leaderstats instead and realized that it does load the saved data but it doesn't save the data. For example, if the player had saved 10k coins from earlier, and it correctly saved. The player joins back and earns another 10k coins and then leaves. It will only load in 10k coins because it doesn't save the coins and will only load the last data that WAS saved.

0
Don't come on this site with alvinbloxx's code, expecting for it to be fixed. User#19524 175 — 6y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?