Hello! I have a UI Where I would like it to show a list of all the banned players from a DataStore, Basically I would like it to list all the keys from the DataStore. How can I do that because the script I made it tells me “DataStores cannot be access by the client”
1 Like
I asked a friend to make this script
local DataStoreService = game:GetService("DataStoreService")
local BanList = DataStoreService:GetDataStore("BannedPlayers")
local function createTextLabel(key)
local textLabel = script.ListItem
textLabel.Text = key
textLabel.Parent = script.Parent
end
local function handleListKeys(keys)
print("List of keys in BannedPlayers DataStore:")
for _, key in pairs(keys) do
print(key)
createTextLabel(key)
end
end
local success, error = pcall(function()
BanList:ListKeysAsync(nil, 50):andThen(handleListKeys):catch(function(err)
warn("Error listing keys:", err)
end)
end)
if not success then
warn("Error:", error)
end
1 Like
You can use a remote function and check if the sender is eligible to view the banned players (the admins/moderators of your game) and return the list of banned player userIds and convert the UserIds to username if needed
I don’t think DataStore returns promises, they return DataStoreKeyPages that functions the same as your regular Page object
Are you able to write the script for me please?