Delete data (RemoveAsync) isn't working

Hi!
I was working on a Delete all data button, it worked yesterday but now it wont, now that I have added the confirm buttons.
What’s wrong?
Thanks!

Delete event

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("Datastore"):WaitForChild("DeleteAllData")
local DSS = game:GetService("DataStoreService")
local FPS = DSS:GetDataStore("SaveData")
local function Del(plr)
	local KEY = "id_"..plr.UserId
	print(plr.Name, " is deleting ALL DATA! 🥵 F in the chat!")
	FPS:RemoveAsync(KEY)
	plr.Leaderstats.FLEX_POINTS.Value = 0
	task.wait(1)
	plr.Leaderstats.Time.Value = 0
end

createPartEvent.OnServerEvent:Connect(Del)

Delete button
(PLEASE don’t comment on the wait’s in between the text, i know!)

script.Parent.MouseButton1Click:Connect(function()
	local txt = script.Parent.Parent.user.Text
	if txt == game.Players.LocalPlayer.Name then
		game.Lighting.UIBlur.Size = 0
		script.Parent.Text = ".. (Verifying)"
		task.wait(5)
		warn("Deleting ALL DATA")
		script.Parent.Parent.Visible = false
		local fade = game.Players.LocalPlayer.PlayerGui:WaitForChild("WelcomeScreen").fadeLoad
		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local createPartEvent = ReplicatedStorage:WaitForChild("Datastore"):WaitForChild("DeleteAllData")
			local plr = game.Players.LocalPlayer
			local KEY = "id_"..plr.UserId
			fade.LAi.Text = "Deleting DataStore keys. [FLEXPOINTS]"
			for i = 1,100 do
				task.wait(0.01)
				fade.TextLabel.TextTransparency -= 0.1
				fade.TextLabel2.TextTransparency -= 0.1
				fade.LAi.TextTransparency -= 0.1
				--it got it some new drip as of 10/22/21, so this isn't needed //fade.BackgroundTransparency -= 0.1
				--replacing it with this instead, looks more modern and goes WITH THE STYLE
				game.Lighting.UIBlur.Size += 1
			end		
			task.wait(2)
			fade.LAi.Text = "Deleting DataStore keys. [TIME]"
			task.wait(3)
			fade.LAi.Text = "Deleting DataStore key. [SETTINGS]"
			task.wait(7)
			fade.LAi.Text = "Deleting DataStore key. [PLOTS]"
			task.wait(10)
			fade.LAi.Text = "Deleting DataStore key. [HOUSES]. This will take a few minutes."
			task.wait(55)
			createPartEvent:FireServer(plr)
			fade.LAi.Text = "Deleded DataStores; resetting PlayerLeaderstatsData."
			local save1 = plr:WaitForChild("leaderstats"):WaitForChild("TIME")
			local save2 = plr:WaitForChild("leaderstats"):WaitForChild("Flex_Points")
			save1.Value = 0
			save2.Value = 0
			fade.LAi.Text = "It never happened. Please wait, finishing up..."
			task.wait(5)
			plr:Kick("\nSorry to see you go!\nAll data was erased.")
	end
end)

Thanks!

Are there any server side errors? You’re going to have to join the game with an account that has access to edit the place, then you’ll get a “Server” option to view server developer logs which will most likely show the error as to why this isn’t working.

Let me check that on my main.

1 Like


I think after the susboy account leaves, it saves the data, because it isnt’ accessing leaderstats from the delete script.

You capitalised the L in leaderstats, it needs to be leaderstats and then try again and it should work.

1 Like