Data Stores not working, attempt to index nil with MainData/Backups

Hello there. So, right now, I have this data script(I am new to making datastores), and everything was going fine, until I actually tested it. Now it uses the same way berezza does it, but the datastore storing backups is a table, and when you load data, it gets number(latest), and loads data with that key. Now something else you should know, there is a big table that stores player data, and the way it works is.

Let’s suppose a script require()ing the module was like, “hey this dude cool, give him 5 points or something idk”. The script will go edit the values in the giant player table. Now the player table is structured like this.

PlayerData-Player-MainData/Backups-stuff goes here

Now, the error is [20:02:34.130 - ServerScriptService.DatastoreHandler:84: attempt to index nil with ‘Backups’]

There is also an error when saving [20:02:37.564 - ServerScriptService.DatastoreHandler:152: attempt to index nil with ‘MainData’]

Here is the code
GETTING DATA:

function dataStoreHandler.GetData(player)
local success, backupData = pcall(function()
	return backupsDataStore:GetAsync(player.UserId..'-backups')
end)
if success then
	if backupData then
		table.sort(backupData, function(a, b)
			return a > b
		end)
		local success, data = pcall(function()
			return mainDataStore:GetAsync(backupData[1])
		end)
		if success then
			playerData[player.Name] = {}
			playerData[player.Name]['MainData'] = {}
			playerData[player.Name]['Backups'] = {}
			
			if data then
				data = UpdateData(data)--If I add a stat
				--(example, kills, this will add it to everybodys
				--data table
				playerData[player.Name]['MainData'] = data
				playerData[player.Name]['Backups'] = backupData
				return playerData[player.Name]['MainData'], playerData[player.Name]['Backups']
			else
				--No player data
				playerData[player.Name]['MainData'] = default
			end
		else
			player:Kick('Failed getting your data, if you lose your data, please contact the devs')
		end
	else
		--No backup data
		playerData[player.Name]['Backups'] = {}
		dataStoreHandler.GetData(player)
	end
else
	player:Kick('Failed getting your data, if you lose your data, please contact the devs')
end

end

To save data:
`function dataStoreHandler.Save(Player)
local data = playerData[Player.Name][‘MainData’]
local plrBackups = playerData[Player.Name][‘Backups’]
table.insert(plrBackups, os.time())
table.sort(plrBackups, function(a, b)
return a > b
end)
local chosenTime = plrBackups[1]
do
local tries = 0
local isSuccess

	repeat 
		tries+=1
		local success, err = pcall(function()
			backupsDataStore:SetAsync(Player.UserId..'-backups')
		end)
		isSuccess = success
		wait(1)
	until isSuccess or tries >= 3
end
local success, err = pcall(function()
	mainDataStore:SetAsync(Player.UserId..'-'..chosenTime)
end)
if not success and err then
	warn(err)
end
playerData[Player.Name] = nil

end
`

Sorry I had trouble formatting, I was in a rush. If you can help me, please do, I am a scripting noob, so I might’ve made a dumb mistake. .-.

Could you provide the lines with errors on them?