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?
Shouldn't it be..
if savedObj == nil then
?