Datastore2 Player being detected as nil error : API call expected {string dataStoreName, Player player}, got {string, nil}

Hello there, I have been trying to figure out Datastore2 (I almost finally got it to work) but I encountered 1 problem which is the error set as my title. It says my player is nil but if I look at my code I do not comprehend when, where or how my player does not exist because my datastore runs under a PlayerAdded:Connect with the player being sent as a parameter (I might of set the player wrong but I do not know how to access the player through ServerScriptService otherwise. I will put the part of the code which I think is causing this issue. I know a few things :

  1. It is definitely inside my StatsHandler PlayerAdded function because the error is started as soon as I join!

  2. I have checked the source code for DataStore2 It errors at this part in particular which is when I call Datastore2(“NameOfDataStore”, Player)

function DataStore2.__call(_, dataStoreName, player)
	assert(
		typeof(dataStoreName) == "string" and IsPlayer.Check(player),
		("DataStore2() API call expected {string dataStoreName, Player player}, got {%s, %s}")
		:format(
			typeof(dataStoreName),
			typeof(player)
		)
	)

	if DataStoreCache[player] and DataStoreCache[player][dataStoreName] then
		return DataStoreCache[player][dataStoreName]
	elseif combinedDataStoreInfo[dataStoreName] then
		local dataStore = DataStore2(combinedDataStoreInfo[dataStoreName], player)

		dataStore:BeforeSave(function(combinedData)
			for key in pairs(combinedData) do
				if combinedDataStoreInfo[key] then
					local combinedStore = DataStore2(key, player)
					local value = combinedStore:Get(nil, true)
					if value ~= nil then
						if combinedStore.combinedBeforeSave then
							value = combinedStore.combinedBeforeSave(clone(value))
						end
						combinedData[key] = value
					end
				end
			end

			return combinedData
		end)

there is 2 Places where I call the DataStore2 Here are these 2 Parts :

-- DataStore2

local DataStore2 = require(ServerScriptService.DataStore2)

-- PlrData default values

local PlrDefaultCash = 0

local PlrDefaultIncrementer = 1

local PlrDefaultRebirths = 0

local PlrDefaultRebirthsPrice = 100

local PlrDefaultEXP = 0

local PlrDefaultEXPReq = 50

local PlrDefaultGold = 0

local PlrDefaultGoldPrice = 1000

local PlrDefaultGemStones = 0

local PlrDefaultReincarnations = 0

-- DataStore2 combine for stats

DataStore2.Combine("PlrData",

"Cash",

"Incrementer",

"Rebirths",

"RebirthsPrice",

"EXP",

"EXPReq",

"Gold",

"GoldPrice",

"GemStones",

"Reincarnations"

)

game.Players.PlayerAdded:Connect(function(Plr)

-- Player DataStores

local CashDataStore = DataStore2("Cash", Plr)

local IncrementerDataStore = DataStore2("Incrementer", Plr)

local RebirthsDataStore = DataStore2("Rebirths", Plr)

local RebirthsPriceDataStore = DataStore2("RebirthsPrice", Plr)

local EXPDataStore = DataStore2("EXP", Plr)

local EXPReqDataStore = DataStore2("EXPReq", Plr)

local GoldDataStore = DataStore2("Gold", Plr)

local GoldPriceDataStore = DataStore2("GoldPrice", Plr)

local GemStonesDataStore = DataStore2("GemStones", Plr)

local ReincarnationsDataStore = DataStore2("Reincarnations", Plr)

After this I insert the values in a folder, make the update functions and what not and after I set some remote functions to access the data and I use DataStore2 Once again.

-- Getters

local function GetCash(Plr)

local Cash = DataStore2("Cash", Plr)

return Cash

end

local function GetIncrementer(Plr)

local Incrementer = DataStore2("Incrementer", Plr)

return Incrementer

end

local function GetRebirths(Plr)

local Rebirths = DataStore2("Rebirths", Plr)

return Rebirths

end

local function GetRebirthsPrice(Plr)

local RebirthsPrice = DataStore2("RebirthsPrice", Plr)

return RebirthsPrice

end

local function GetEXP(Plr)

local EXP = DataStore2("EXP", Plr)

return EXP

end

local function GetEXPReq(Plr)

local EXPReq = DataStore2("EXPReq", Plr)

return EXPReq

end

local function GetGold(Plr)

local Gold = DataStore2("Gold", Plr)

return Gold

end

local function GetGoldPrice(Plr)

local GoldPrice = DataStore2("GoldPrice", Plr)

return GoldPrice

end

local function GetGemStones(Plr)

local GemStones = DataStore2("GemStones", Plr)

return GemStones

end

local function GetReincarnations(Plr)

local Reincarnations = DataStore2("Reincarnations", Plr)

return Reincarnations

end

after this bit of code all it is is my Pointers to my data, and some functions I need inside the statshandler!

I hope this is detailed enough to get some help.

Thanks in advance!
– Scripteor

PS: I have checked the dev forums to try and find a solution, read the api for Datastore2 multiple times and watched videos on how to use it properly with no luck at it working

Have you found a solution? This still affects me.

This is probably because the player is not ready yet.
Try this:
game.Players.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(char)
– do char stuff
end)
end)

This will wait for the player to be ready before running the code.