I am working on a game where players can write messages and others can see them. In case a message is inappropriate, I have added a report system and if I believe the message is inappropriate, I press a button and the code uses datastore:RemoveAsync().
- What do you want to achieve? Keep it simple and clear!
I want to permanently delete a key from a globaldatastore.
- What is the issue? Include screenshots / videos if possible!
I have deleted data from the key but key seems to still exist when i use datastore:ListKeysAsync()
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked at other forum pages and I can’t find an answer that fits my code.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
IMPORTANT INFORMATION:
rl = datastore for list of reports this code is okay
ds = datastore for each message posted. each player can only post one message so i am saving each message to the players userid as the key
Take a look at the code inside of the if statement that wonders if I think the player is innocent or if their message needs to be removed.
game.ReplicatedStorage.Events.Quotes.RateReport.OnServerInvoke = function(plr,reportedid,rating)
local data
local s, e = pcall(function()
data = rl:GetAsync("List1")
end)
if s then
if data then
data = game:GetService("HttpService"):JSONDecode(data)
local found
local listnum = 1
for i, v in pairs(data) do
print(v["Id"],reportedid)
if tonumber(v["Id"]) == tonumber(reportedid) then
found = v
listnum = i
end
end
--print(found,listnum)
if found then
if rating == "Innocent" then
print(data)
table.remove(data,listnum)
print(data)
pcall(function()
rl:SetAsync("List1",data)
end)
elseif rating == "Remove" then
table.remove(data,listnum)
local d
local success, errormessage = pcall(function()
d = ds:GetAsync(tonumber(reportedid))
end)
if success then
if d then
local s1, e1 = pcall(function()
ds:RemoveAsync(tonumber(reportedid))
end)
if s1 then
return true,"Successfully removed quote from report list and game data."
else
return false,"Successfully removed report off of list, but did not remove quote: "..e1
end
else
return false,"There is no quote to remove."
end
else
return false,"Successfully removed report off of list, but did not remove quote: "..errormessage
end
end
else
return false, "Quote not on report list."
end
else
return false,"Could not load list to remove from."
end
else
return false,e
end
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.