I am trying to add onto an array stored in the DataStore yet when I insert 1 into the Array the output of the NewArray is nil. I know I must be missing something quite obvious yet I have been unable to solve this for some time now. Help is much appreciated, thanks.
Example:
-- Player is correctly defined.
local DataStore = game:GetService("DataStoreService"):GetDataStore("Data")
DataStore:SetAsync(Player.UserId, {})
local Array = DataStore:GetAsync(Player.UserId)
local NewArray = table.insert(Array, 1) -- Output is nil
DataStore:SetAsync(Player.UserId, NewArray)