So, I'm playing around with data stores and attempting to change a playerAs data store values based on another playerBs actions.. Sadly, I apparently can't get playerAs data to update.. it always returns nil..
function DataStore:UpdateStatus(player, isOnline)
output("Update")
if not DataStore.isPlayerLoaded(player) then
repeat wait() output("Waiting for Player:", player)
until DataStore.isPlayerLoaded(player)
else
output("Player is loaded.", player)
output("DataSize:", #sessionData[player])
end
for i = 1, #sessionData[player] do
local friendID = game.Players:GetUserIdFromNameAsync(sessionData[player][i]["Name"])
output("DEBUG", friendID)
if friendID ~= nil then
output(player, ":", sessionData[player][i]["Name"], "::", friendID)
end
local playerData = FriendData:GetAsync(friendID)
output("DEBUG", playerData)
if playerData ~= nil then
for i, v in pairs(playerData) do
output("DEBUG", i, v)
end
FriendData:SetAsync(game.Players:GetUserIdFromNameAsync(sessionData[player][i]["Name"], playerData))
end
end
end
Output
[MOD_SERVER_FRIENDS] DEBUG 26517
[MOD_SERVER_FRIENDS] Player1 : Player2 :: 26517
[MOD_SERVER_FRIENDS] DEBUG nil

1 comment
It always returns nil because it isn't set to anything. A data store will return nil if the key has not been used or there's simply nothing in it.