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

Why doesn't it save the data in this dataStore script?

Asked by 5 years ago

I'm making a data store script and I can't seem to see an error. There is no error in the output either. Here is my script, pls fix if possible.

01local DSS = game:GetService("DataStoreService")
02local cashDSS = DSS:GetDataStore("CurrencyStore")
03 
04game.Players.PlayerAdded:Connect(function(plr)
05 
06    local leaderstats = Instance.new("Folder",plr)
07    leaderstats.Name = "leaderstats"
08 
09    local Currency = Instance.new("IntValue", leaderstats)
10    Currency.Name = "Bucks"
11 
12    local data
13 
14    local success, errormsg = pcall(function()
15        data = cashDSS:GetAsync(plr.UserId.."-Bucks")
View all 41 lines...

I appreciate your time and effort. Thanks for helping.

1 answer

Log in to vote
1
Answered by
birds3345 177
5 years ago
Edited 5 years ago

This happened to me when I was making a datastore, but I found a fix. There is a roblox function called game:BindToClose, this event fires when all the players leave and keeps the server open until what is inside the function is done running. I suggest you make a function like SaveData so that way you don't have to put 2 duplicates of your code in 2 places. I really hope this helped.

0
Thanks I'll try it out now kingblaze_1000 359 — 5y
Ad

Answer this question