How to add to this table in a DataStore?

I have a data store table that has a list of jobs and players that have the job, I can add to it fine as seen below

local jobEmployeeStore = DataStoreService:GetDataStore("JobEmployees")
local jobEmployeeData = jobEmployeeStore:GetAsync("jobs_key")
			
table.insert(jobEmployeeData[job], player.Name)
			
local Success, errorMessage = pcall(function()
    jobEmployeeStore:SetAsync("jobs_key", jobEmployeeData)
end)
if not Success then
    print(errorMessage)
end

But when I :GetAsync again and try to iterate through the table, I get this

local jobEmployeeStore = DataStoreService:GetDataStore("JobEmployees")
local jobEmployeeData = jobEmployeeStore:GetAsync("jobs_key")
		
for i,v in pairs(jobEmployeeData[job]) do
	print(i)
end

The second script function is to remove the player from the table, but I can’t even get it to iterate through the table in order to then table.remove the player name. How can I solve this?

1 Like

I may be wrong but don’t you need to use the player.userId when using datastore? Also have you tried using UpdateAsync?

You can save with any key, and yeah I know UpdateAysnc is better than GetAsync but that’s not the issue rn, I don’t think