I currently making my data store but the problem is it really return old value if the data store fails to load it however it only load 1 data which is for Wins not all data can somebody help me and figure it out?
local function Get(plr)
local key = "plr-" .. plr.UserId
local name = plr.Name
IsInGame[key] = false -- When they just join
local data
local count = 0
dataLoaded[key] = false
local sucess, err
if IsInGame[key] == false then
repeat
sucess, err = pcall(function()
data = myDataStore00001:GetAsync(key)
end)
count = count + 1
if not sucess then
dataLoaded[key] = false
end
if count >= 2 then
wait(Slowdown) -- Slow Down The Process ; Repeats
end
until count >= tries or sucess or not Players:FindFirstChild(name)
end
-- individual
if not sucess then
dataLoaded[key] = false
warn("Failed to read. Data. Error code: " .. tostring(err))
return
end
if sucess then
if data then
dataLoaded[key] = true
return data
else
return {
["Coins"] = 0,
["Win"] = 0,
["Levels"] = 0,
["Exp"] = 0,
["PurpH"] = 0,
}
end
end
end
Example :
Wins from 0 to 1 because it return however the level is still level 0?