How to add new values to a data store without overwriting old data

This is my first time trying to achieve this as I only know about overwriting data, which isn’t very helpful in my case.
Here’s my awful code which may make some laugh :sob:

		local userModerationLogs = {}
		local newEntry = {}
		newEntry["Moderator"] = plr.Name
		newEntry["Action"] = Action
		newEntry["Date"] = tostring(os.date("%x"))

		
		Objects.ModActionsLog:UpdateAsync(Services.Players:GetUserIdFromNameAsync(User), function(oldData)
			return table.insert(oldData, userModerationLogs)
		end)

If you have solution to this it would greatly appreciated!

Assuming oldData is the player’s datastore information it should be as simple as this:

		local newEntry = {}
		newEntry["Moderator"] = plr.Name
		newEntry["Action"] = Action
		newEntry["Date"] = tostring(os.date("%x"))

		
		Objects.ModActionsLog:UpdateAsync(Services.Players:GetUserIdFromNameAsync(User), function(oldData)
			return table.insert(oldData, newEntry)
		end)

All this does it just adds another table/dictionary to the preexisting player data table.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.