How to remove a data from a purchase history?

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to remove a data from a purchase history data store which uses this key: receiptInfo.PlayerId … “_” … receiptInfo.PurchaseId.

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


    I am following this however this assumes the datastore uses Player_XXXXXXXX as a key. Since I process purchase with a different script, I do not know how I can get receiptInfo.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?


I have tried to do this in hopes of printing data, but I get “nil” 3 times. Then I learned “PurchaseId” type is a string. I realized I have placed a number value. I want to be able to remove a purchase history in my games, but I do not know how. What can I do?

the script saving purchase history:

Can’t you just use tonumber() to convert the string into a number value?

hey thanks for the response. I’ve tried using “tonumber()” but sadly I still get “nil”. I think one solution for me is to change the key format of the purchase history datastore, but I have two players who have already made a purchase. If Roblox sends me a letter saying, “delete data” for these two players, I wouldn’t be able to (because I only changed the key format)

Wait wait wait.

He says he placed a number value. This means tonumber() is rendered absolutely useless, as it gives the same output. Shouldn’t he use tostring() instead?

good point. I did try using tostring() but I still get “nil”. I think it’s impossible to create a key for the purchase history data store on a separate script (since it’s using receiptInfo and there’s no way to access the receiptInfo).

The proper syntax for RemoveAsync() is using the name of the key saved:

local datastore = game:GetService("DataStoreService"):GetDataStore("UserData")
datastore:RemoveAsync("Player_12345678")

I should have named my key like “Player_1234567” when saving the purchase history. It would have made things easier.