Datatstore very rarely not saving for players

With the way you’ve structured it, yes. The solution I provided should fix that issue. Other people also store a “version” value alongside the main data, that is incremented every time the data is saved. Then, when updating the player’s data, they check the version from the old data with the version from the new data, and if the version from the old data is higher than the new data, that means the new data is actually outdated. This partially fixes the issue of players joining right after leaving another server (but players will still lose the progress from the new session)

You can absolutely attempt to load it until it is successful, it would look something like this

local function GetData(Key, MaxRetries)

	local Retries = 0

	while true do 

		local Success, Result = pcall(function()
			return Datastore:GetAsync(Key)
		end)

		if Success then 
			return true, Result
		else 
			warn("[GetData]: "..Result)

			Retries += 1
			if Retries > MaxRetries then -- Give up :(
				return false, nil
			end
			
			-- Exponential backoff (increases the wait, to alleviate the load on roblox's servers if they go down)
			task.wait(2^Retries)

			continue
		end

	end
end

You can also look into ProfileStore, which has session locking and all the features to keep data safe. I am not sure if it is easy to convert to it though

2 Likes