Why will my autosave system only save for one player?

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local DataStore = DataStoreService:GetDataStore("Data")

while true do
	for _, Player in Players:GetPlayers() do
		local Retries = 0
		repeat
			success, errormessage = pcall(function()
				DataStore:UpdateAsync(Player) -- I made it fail on purpose to test the retrying system
			end)
			print(Player.Name)
			Retries += 1
			warn(Retries)
			task.wait(Retries)
		until
		success or Retries >= 5
	end
	task.wait(3) -- I only made a low wait time to test the system
end

I tested this in a local server on studio with 2 players, it only saves one person’s data again and again when it should be doing both since it loops through all players I’m pretty sure.

hey, i had this same issue. Test it in a published game in the Roblox player instead. For some reason it seems that only the Owner can fully use DataStoreService in studio

1 Like

I’ve published the game but yeah I’ll test it in actual server although I just tested it in a local server again and it seemed to have worked.

Ok I’m not sure whether I was hallucinating or not but basically I tried the same code again in a local server and it worked properly, or it might be because of what @azavier123 said.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.