How to transfer older user data from older datastore without wiping it?

I currently updated my game’s data compressing structure, it’s much more efficient however, the problem is that all the players that played it before will lose their data, I would like to know if there is a way to transfer that older user data to a newer datastore?

1 Like

you can add this script

local DataStoreService = game:GetService("DataStoreService")
local oldDataStore = DataStoreService:GetDataStore("olddatastore")
local newDataStore = DataStoreService:GetDataStore("newdatastore")
game.Players.PlayerAdded:Connect(function(Plr)
	local Data
	local Suc, Err = pcall(function()
		Data = newDataStore:GetAsync(Plr.UserId) -- change to key you use now
	end)
	if Data and Suc then
		-- load data
	elseif Suc == true then -- old data store
		local Suc, Err = pcall(function()
			Data = oldDataStore:GetAsync(Plr.UserId) -- change to key you used to use
		end)
		if Suc and Data then
			-- load data
		end
	end
end)