Utilizing tables in datastore

I am trying to use a table with its arrays being strictly strings linked to player for saving, but upon executing the debug method, the table is nil.

function GetTableRanks(UserId)
	return DataStore:GetDataStore("playerData"):GetAsync(UserId.."codes")
end
function Engine:DataTable(Method, ID, Code)
	if Method:lower():match("has") then
		if table.find(GetTableRanks(ID), Code) then
			return true
		end
		return false
	end
	if Method:lower():match("add") then
		table.insert(GetTableRanks(ID), Code)
	end
	if Method:lower():match("debug") then
		print(GetTableRanks(ID))
	end
end
--
local Ranks = {}
--PlayerAdded Connection
playerData:GetAsync(player.UserId.."codes",Ranks)
--PlayerRemoving Connection
playerData:SetAsync(player.UserId.."codes",Ranks)

bump. any alternatives to my approach?

there is not enough code here to help seems you may not actually be setting the data correctly

wdym not enough? what do i have to show i just need to know why that functions returns nil instead of the table

well this from what I read never sets anything

and if you only setting when the player leaves it most likely is not saving before the server shuts down you would need to auto save over time or when the data is changed most tiles set a table of players whos data has changed and then in a while loop over say 1 minute or so go through that table and save those players data setting the table value to nil for the next change

with the code you have there ranks could be nil or even global

I know that, I have bindtoclose function for that scenario my main goal is just have a table linked to player, save it and then use it for functions and ranks is just a blank table, do i have to use global tables or what like this

_G.Ranks = {} _G.Ranks[game:GetService("Players").weakroblox35] = {"lol"} print(_G.Ranks[game:GetService("Players").weakroblox35])

apparently yeah i am forced to use global tables for this

local plr = game:GetService("Players").weakroblox35 _G.Ranks = {} _G.Ranks[plr] = {"lol", "yeh"} if table.find(_G.Ranks[plr], "lol") then print(true) end