I am currently making a ban command for my game, I don’t know how to update a table through a datastore, Anyone help?
1 Like
Try experimenting with datastore API, tables.
Hello ![]()
The developer forum has a few articles about data stores so have a look and they will help
Good Luck
If you simply want to update an index within the table then just use UpdateAsync.
datastore:UpdateAsync(key, function(oldValue)
-- We expect oldValue to be a table
oldValue = oldValue or {}
-- Set the value
oldValue["index"] = value
return oldValue
end)
1 Like
local function banplayer(plr)
local t = {}
local bans = game:GetService("DataStoreService"):GetDataStore("Bans"):GetAsync("List")
for i,v in pairs(bans) do
table.insert(t,v)
end
table.insert(t,plr)
game:GetService("DataStoreService"):GetDataStore("Bans"):SetAsync("List",t)
end