I'm trying to remove(or reset the value) this user's data from the leaderboard

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to remove(or reset the value) this user’s data from the leaderboard.

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried using the “:RemoveAsync()” function as well as the “:Destroy()”, but neither worked. They would destroy/delete the data, but as soon as I remove them, the user would show back up with their previous data. I have tried looking for possible solutions on Developer Hub, but I couldn’t one that worked for me.

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!

local donateAmounts = {10, 25, 50, 100, 250, 500, 1000, 5000, 10000}
local ids = {1539802861, 1539803017, 1538253430, 1539803224, 1539803619, 1539803823, 1539803955, 1539805952, 1539806386}


local mps = game:GetService("MarketplaceService")

local dss = game:GetService("DataStoreService")
local ods = dss:GetOrderedDataStore("Donators")



for i, amount in pairs(donateAmounts) do
	
	local donateButton = script:WaitForChild("DonateButton"):Clone()
	donateButton.Text = amount .. " Robux"
	donateButton.TextScaled = true
	donateButton.Parent = script.Parent.Donation.DonateGui.DonateList
end


game.ReplicatedStorage.DonateRE.OnServerEvent:Connect(function(plr, button)
	
	
	local amount = string.gsub(button.Text, " Robux", "")
	local id = ids[table.find(donateAmounts, tonumber(amount))]
	
	mps:PromptProductPurchase(plr, id)
end)


mps.ProcessReceipt = function(purchaseInfo)
	
	local amount = mps:GetProductInfo(purchaseInfo.ProductId, Enum.InfoType.Product).PriceInRobux
	
	local success, err = pcall(function()
		local totalDonated = ods:GetAsync(purchaseInfo.PlayerId) or 0
		ods:SetAsync(purchaseInfo.PlayerId, totalDonated + amount)
		--ods:RemoveAsync()
	end)
	
	return success and Enum.ProductPurchaseDecision.PurchaseGranted or Enum.ProductPurchaseDecision.NotProcessedYet
end


while wait(5) do
	
	for i, child in pairs(script.Parent.LeaderboardPart.LeaderboardGui.LeaderboardList:GetChildren()) do
		
		if child:IsA("Frame") then child:Destroy() end
	end
	
	
	local pages = ods:GetSortedAsync(false, 100)
	local top = pages:GetCurrentPage()
	
	
	for rank, data in ipairs(top) do
		
		local username = game.Players:GetNameFromUserIdAsync(data.key)
		local donated = data.value
		--username:RemoveAsync()
		--username:SetAsync()
		
		local leaderboardFrame = script.LeaderboardFrame:Clone()
		leaderboardFrame.Rank.Text = "#" .. rank
		leaderboardFrame.Username.Text = username
		leaderboardFrame.Amount.Text = donated
		
		leaderboardFrame.Parent = script.Parent.LeaderboardPart.LeaderboardGui.LeaderboardList
	end
end
1 Like

You may have to rename

local ods = dss:GetOrderedDataStore(“Donators”)

“Donators” May have to be renamed to Donators_1 to replace and erase the data.

Hope that helps!