How to read all datastore values

basically i have a ban datastore and a hacker banned like 60 players and i dont really have the time to search through all players to find the banned ones

how would i unban all players or make it print the players that are banned

if you know how, please do tell me because i am really stumped

3 Likes

you can just reset the datastore. use a new datastore key and just start from scratch

1 Like

how would i reset the datastore completely

Although I’ve never used it myself, I think you can look into ListKeysAsync.

1 Like

i want to have a script where it unbans everyone that is banned and doesnt
need to reset the datastore

1 Like

but I’m saying its the same thing

after u unban everyone, the table will look like this {}

after you reset the datastore, the table will look like this {}

And to reset it, simply change the datastores name

local banStore = DataStoreService:GetDataStore("BanList")

by changing the “BanList” part we can change datstores

2 Likes
local DataStoreService = game:GetService("DataStoreService")

local banDatastore = -- add datastore line here

local success, pages = pcall(function()
	return banDatastore:ListKeysAsync(nil, 200, nil, true)
end)

if success then
	local page = pages:GetCurrentPage()

	for i, info in page do
		local success, value = pcall(function()
			return banDatastore:GetAsync(info.KeyName)
		end)

		if success then
			print(`Key: {info.KeyName}, Value: {value}`)
		end

		--local success, value = pcall(function()
		--return banDatastore:RemoveAsync(info.KeyName)
		--end)
		-- Uncomment to remove key from datastore
	end
end
1 Like

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