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

Data loss with DataStore?

Asked by 9 years ago

Right now im using a while true do loop that saves every 5 seconds but im having a lot of data loss

does it have something to do with the load script or with the save script?

here are the scripts im using right now

Load

player = script.Parent.Parent.Parent.Parent

local Datastore = game:GetService("DataStoreService"):GetDataStore("OBJ")

local key = "player-"..player.userId

local savedObj = Datastore:GetAsync(key)

if savedObj then
    Value1 = savedObj[1]
    Value2 = savedObj[2]
    Value3 = savedObj[3]
else
    local objToSave = {Value1, Value2,Value3}
    Datastore:SetAsync(key, objToSave)
end



Save

player = script.Parent.Parent.Parent.Parent

local Datastore = game:GetService("DataStoreService"):GetDataStore("OBJ")

while true do
    local key = "player-"..player.userId
local objToSave = {Value1,Value2,Value3}
    Datastore:SetAsync(key, objToSave)
    wait(5)
end

value1 value2 and value3 are just examples

anything wrong with my script?

1 answer

Log in to vote
0
Answered by 9 years ago

Shouldn't it be..

if savedObj == nil then

?

0
above @centraltrain its the same thing as what the poster has iwilllandonmars 55 — 9y
Ad

Answer this question