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

DataStore2 and DataStore not saving a set table of bool values?

Asked by
Donut792 216 Moderation Voter
6 years ago

so i have tried both DataStore and DataStore2 to save a list of boolvalues for me and its not saving when it changes but in the server log it says that it does, but it doesnt i do have a DataStore that saves another set of boolvalues and it works just fine even being a regular DataStore

here is the script i got to save them

01local DS2 = require(1936396537)
02 
03game.Players.PlayerAdded:Connect(function(plr)
04    local speedData = DS2('Speed', plr)--Get the speed datastore
05    local healthData = DS2('Health', plr)--Get the health datastore
06    --Speed
07    local Speed = Instance.new("Folder")
08    Speed.Name = "Speed"
09    Speed.Parent = plr
10    local Five = Instance.new("BoolValue")
11    Five.Name = "Five"
12    Five.Parent = Speed
13    local Ten = Instance.new("BoolValue")
14    Ten.Name = "Ten"
15    Ten.Parent = Speed
View all 98 lines...

when the values change the server does print Saved MaxHealth Data but when a player rejoins the value is back at false

0
Your table will take time for the datastores to SetAsync PenguinDevs 45 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Yo, I think that I might see the solution epescially for your type of tables that are very large and may take a little longer to SetAsync, you should add in a :BindToClose and then add in a wait, so it gives your Datastores to Setasync I used to have the same problem as you, this is what helped me from the past

1game:BindToClose(function()
2    if runservice:IsStudio() then
3        --wait(2) --Turn on/off wether you wanna enable it on studio
4        return
5    else
6        wait(2)
7    end
8end)

Feel free to paste it on your script(Also it's highly recommended that you dont delete the comments on line 3, because your studio won't respond if you use a wait for bind to close on studio

0
alright thanks man i didnt really think about using bindtoclose on datastore2 Donut792 216 — 6y
0
DataStore2 uses BindToClose already when saving data. Kampfkarren 215 — 6y
Ad

Answer this question