I am trying to remove a player's user ID from a datastore, but remove async is not working. I used the right kind of parameters and everything, and it's not removing the data. Also, I'm using an ordered data store. When I tried printing it, it returned nil as well.
Script:
local function accumulate()
local list = {}
local nilCount = 0
local key = 1
while true do
local value
local success, notSuccess = pcall(function()
value = dataStoreService:GetAsync(key)
end)
if success then
print("Value obtained")
else
warn(notSuccess)
end
if value == nil then
nilCount = nilCount + 1
else
table.insert(list, value)
end
if nilCount >= 2 then break end
key = key + 1
end
return list
end
local function reorderData()
local data = accumulate()
local key = 1
for _, value in pairs(data) do
local success, notSuccess = pcall(function()
dataStoreService:SetAsync(key, value)
end)
if success then
print("Data ordered")
else
warn(notSuccess)
end
key = key + 1
end
print("Data Reordered")
end
local function removePlayer(player, plr)
local key = 1
local ID
while true do
local success, notSuccess = pcall(function()
ID = dataStoreService:GetAsync(key)
end)
if success then
print("Got player")
else
warn(notSuccess)
end
if plr.UserId == ID then
print("Found")
local success, notSuccess = pcall(function()
local remove = dataStoreService:RemoveAsync(tostring(key))
print(remove)
end)
if success then
print("Unbanned Player")
else
warn(notSuccess)
end
break
end
key = key + 1
end
reorderData()
return 0
end
