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 5 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:

local DSService = game:GetService('DataStoreService'):GetDataStore('XIPHER_921838582315538283812581238529158283')
game.Players.PlayerAdded:connect(function(plr)
 -- Define variables
 local uniquekey = 'id-'..plr.userId
 local savevalue =  plr.PlayerGui:WaitForChild("Cash").CashFrame.MoneyHolder.Money.MoneyHolder
 -- GetAsync
 local GetSaved = DSService:GetAsync(uniquekey)
 if GetSaved then
  savevalue.Value = GetSaved[1]
 else
  local NumbersForSaving = {savevalue.Value}
  DSService:SetAsync(uniquekey, NumbersForSaving)
 end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.PlayerGui:WaitForChild("Cash").CashFrame.MoneyHolder.Money.MoneyHolder.Value}
DSService:SetAsync(uniquekey, Savetable) 


end)

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 — 5y

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?