How to Remove my Data From My Datastore Script

I’m Trying to make a Donation Board Script But I Don’t want Myself in the leaderboard
How can I Make it

local DonateAmounts = {
	5,
	10,
	50,
	100,
	500,
	1000
}
local DonationIDs = {
	1298214298,
	1298214869,
	1298215285,
	1298220710,
	1298221269,
	1298221625
}

local CashProductIDs = 
	{
		[1334471867] = 10,
		[1334455568] = 50,
		[1334462068] = 100,
		[1334466040] = 500,
	}


local MarketplaceService = game:GetService("MarketplaceService")

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

game.Players.ChildAdded:Connect(function(Player)

	for i, amount in pairs(DonateAmounts) do

		local donateButton = script:WaitForChild("DonateButton"):Clone()
		donateButton.Text = amount .. " Robux"
		donateButton.Parent = Player:WaitForChild("PlayerGui"):WaitForChild("Screen").DonationFrame.Donate.DonateList
	end

	game.ReplicatedStorage.DonateRE.OnServerEvent:Connect(function(Player, button)


		local amount = string.gsub(button.Text, " Robux", "")
		local id = DonationIDs[table.find(DonateAmounts, tonumber(amount))]

		MarketplaceService:PromptProductPurchase(Player, id)
	end)

	MarketplaceService.ProcessReceipt = function(purchaseInfo)

		spawn(function()
			local PlayerPurchased = game.Players:GetPlayerByUserId(purchaseInfo.PlayerId)

			if not PlayerPurchased then

				return Enum.ProductPurchaseDecision.NotProcessedYet
			end


			for productID, coinsGiven in pairs(CashProductIDs) do

				if purchaseInfo.ProductId == productID then


					PlayerPurchased.PlayerData.Cash.Value = PlayerPurchased.PlayerData.Cash.Value + coinsGiven

					return Enum.ProductPurchaseDecision.PurchaseGranted
				end
			end
		end)


		local amount = MarketplaceService:GetProductInfo(purchaseInfo.ProductId, Enum.InfoType.Product).PriceInRobux

		local success, err = pcall(function()
			local totalDonated = Donators:GetAsync(purchaseInfo.PlayerId) or 0
			Donators:SetAsync(purchaseInfo.PlayerId, totalDonated + amount)
		end)

		return success and Enum.ProductPurchaseDecision.PurchaseGranted or Enum.ProductPurchaseDecision.NotProcessedYet
	end

	spawn(function()
		while task.wait(5) do
			for i, child in pairs(Player:WaitForChild("PlayerGui"):WaitForChild("Screen").DonationFrame.Leaderboard.LeaderboardList:GetChildren()) do
				if child:IsA("Frame") then
					child:Destroy()
				end
			end

			local pages = Donators: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

				local leaderboardFrame = script.LeaderboardFrame:Clone()

				leaderboardFrame.Rank.Text = "#" .. rank
				
				leaderboardFrame.Username.Text = username

				leaderboardFrame.Amount.Text = donated

				leaderboardFrame.Parent = Player:WaitForChild("PlayerGui"):WaitForChild("Screen").DonationFrame.Leaderboard.LeaderboardList
			end
		end
	end)

end)



Not sure if this will work for you but basically. Go in ACTUAL REAL GAME and then type /console in chat. Click server and then at the bottom you can see you can type stuff into it. Paste the following into the text box:

game:GetService("DataStoreService"):GetDataStore("Donators"):IncrementAsync(your id, or anyone else's id you want to remove, -5250 <-- Amount of robux your removing)
1 Like

If you want to completely erase a players data and make it nil, rather than just 0, you can use :RemoveAsync. Below is an example, recommend you paste this into studio console.

local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetOrderedDataStore("Donators") --name

local succ, val = pcall(function()
	return DataStore:RemoveAsync(1201454998) -- key
end)

1 Like

No i dont want to erase everyones data, i just want to erase mine only

You don’t have to, as long as you enter the cooresponding key in the RemoveAsync portion it should work fine

local succ, val = pcall(function()
	return DataStore:RemoveAsync(1201454998) -- replace 120145998 with the key you want to remove
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.