There are many tutorials on this like on lua learning there is a ban player list. Also theres a plugin for this script that @Ozzypig had created, the following topic links to the plugin:
yeah datastores should be like one of the first things you handle in your game.
(if data saving is needed)
once you understand datastores and got your banned list working you can just do something like…
local list = {}
local success, err = pcall(function()
list = datastore:GetAsync("BannedList")
end)
if(success)then
for i, v in ipairs(list) do
local name = v.Name
local userId = v.UserId
-- now use all the data you saved to visualize the list. (using a scrollframe with a listLayout)
end
end
you can send the data over to the client with remote events. (or you can just update the PlayerGui directly from the server, i never noticed any difference in speed)
You could use a remotefunction to grab the list of banned players. To make a list of banned players first you must access the ‘ban’ datastore. To make a datastore is simple this is legit all you have to do:
local Data = game:GetService("DataStore"):GetData("BanList")
function BanPlayer(UserId)
if Data:GetAsync("BannedPlayers") then
local bannedPlayers = Data:GetAsync("BannedPlayers")
bannedPlayers[UserId]=true
Data:SetAsync("BannedPlayers", bannedplayers)
else
bannedplayers = {}
bannedplayers[UserId]=true
Data:SetAsync("BannedPlayers", bannedplayers)
end
end
that function you can run when you ban anyone. then you can make another function to grab the list of players here:
local remotefunction = game.ReplicatedStorage:WaitForChild("BanRemote") -- remotefunction
remotefunction.OnServerInvoke = function()
local data = Data:GetAsync("BannedPlayers")
if data then
return data
end
end
so what does the function above do exactly? what it does is when you invoke the server from the client that script will return the table of banned players back to you. you can then from there on make a for loop instancing textlabels with whatever you want into a frame with ‘UIListLayout’ inside of it. Make sure to clear the frame whenever you want to refresh though!