I’m not really sure what is happening, i call :RemoveAsync() but the key doesn’t get removed?
additionally, the result always prints out nil?
i’m really confused
Code that calls :RemoveAsync()
local rStorage = game:GetService("ReplicatedStorage")
local dStoreService = game:GetService("DataStoreService")
-- Path to event;
local events = rStorage:WaitForChild("Events")
local adminEvents = events:WaitForChild("AdminEvents")
-- Event;
local removeFeedback = adminEvents.RemoveFeedback
-- Datastore;
local feedbackData = dStoreService:GetDataStore("FeedbackData")
local bannedPlayersData = dStoreService:GetDataStore("FeedbackBans")
removeFeedback.OnServerEvent:Connect(function(plr, feedbackFrame: Frame, isBan: boolean)
if plr.UserId ~= 473208961 then
plr:Kick("What exactly are you trying to accomplish?")
return
end
if isBan == true then
local playerToBan = tonumber(feedbackFrame.Name)
if playerToBan then
local success, result = pcall(function()
bannedPlayersData:SetAsync(tostring(playerToBan), true)
end)
if success then
print(playerToBan .. " " .. "Has been banned from submitting feedback.")
local removeSuccess, removeResult = pcall(function()
feedbackData:RemoveAsync("Feedback_" .. playerToBan)
end)
if removeSuccess then
print("Additionally, the feedback has been removed from the database.")
else
warn("Failed to remove the feedback from the database! " .. removeResult)
end
else
warn("Failed to ban " .. playerToBan .. ": " .. result)
end
end
else
local feedbackToRemove = tonumber(feedbackFrame.Name)
if feedbackToRemove then
local success, result = pcall(function()
feedbackData:RemoveAsync("Feedback_" .. feedbackToRemove)
end)
if success then
print("Successfully removed feedback!")
print(result) -- prints nil?
else
warn("Failed to remove feedback: " .. result)
end
end
end
end)
maybe it’s something to do with the code that handles the feedback data?
local dStoreService = game:GetService("DataStoreService")
local sStorage = game:GetService("ServerStorage")
local feedbackData = dStoreService:GetDataStore("FeedbackData")
local feedbackFrames = sStorage:WaitForChild("FeedbackFrames")
local mainFrame = feedbackFrames:WaitForChild("MainFrame")
local feedbackFrame = feedbackFrames:WaitForChild("FeedbackFrame")
function GetAllFeedback()
local feedbackList = {}
local success, result = pcall(function()
local pages = feedbackData:ListKeysAsync("Feedback_")
while true do
for _, entry in ipairs(pages:GetCurrentPage()) do
local key = entry.KeyName
local feedback = feedbackData:GetAsync(key)
if feedback then
table.insert(feedbackList, feedback)
end
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
end)
if success then
return feedbackList
else
warn("Failed to receive feedback list! " .. result)
return nil
end
end
local allFeedback = GetAllFeedback()
print(allFeedback)
for _, feedback in ipairs(allFeedback or {}) do
local scrollingFrame = mainFrame.ScrollingFrame
local clonedFeedbackFrame = feedbackFrame:Clone()
local textButton = Instance.new("TextButton")
textButton.Name = feedback.Player
textButton.Size = UDim2.new(1,0,0.1,0)
textButton.Text = "Feedback_" .. feedback.Player
textButton.TextScaled = true
textButton.Parent = scrollingFrame
clonedFeedbackFrame.Name = feedback.Player
clonedFeedbackFrame.FeedbackSource.Text = feedback.Player
clonedFeedbackFrame.FeedbackTopic.Text = feedback.Topic
clonedFeedbackFrame.FeedbackElaboration.Text = feedback.Elaboration
clonedFeedbackFrame.Parent = mainFrame
end
visual presentation of what’s happening: