how to delete user id from data store roblox
To delete a user’s data from a Roblox DataStore, use RemoveAsync with the
exact key that was used to save that user’s data. If you saved data by
UserId, the delete call should use that same UserId-based key; if you used
a prefix like Player_12345, you must remove that full key.
Basic example
lua
local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("DataStoreName")
local userId = 4760160964
local key = "Player_" .. userId
local success, err = pcall(function()
ds:RemoveAsync(key)
end)
if not success then
warn(err)
end
RemoveAsync(key) deletes that entry, and Roblox forum examples also note
that setting a key to nil can remove it in some cases, though RemoveAsync
is the clearer option.
What matters most
- Use the same key format you used when saving the data.
- If the data is stored in multiple DataStores, delete it from all of them.
- If your game also stores player info elsewhere, remove it there too, not just in DataStore.
If the key is just the UserId
lua
local ds = game:GetService("DataStoreService"):GetDataStore("DataStoreName")
ds:RemoveAsync("4760160964")
That works only if the data was stored with the UserId as the exact key.
For right-to-erasure requests
Roblox forum guidance says to delete the user’s data from every datastore you use, and to clean up any external databases as well if you have them.
TL;DR: find the exact key format you used, then call RemoveAsync on
every DataStore that contains that user’s data.