Quoting the article on Datastores (https://developer.roblox.com/articles/Data-store) :
1 | local DataStoreService = game:GetService( "DataStoreService" ) |
3 | local experienceStore = DataStoreService:GetDataStore( "PlayerExperience" ) |
5 | local success, err = pcall ( function () |
6 | experienceStore:SetAsync( "Player_1234" , 50 ) |
That script basically gets the DataStoreService, then gets the data store called "PlayerExperience"
You can set values such as :SetAsync(Player, Ban) where ban would be a bool value.
You can use GetAsync(Player) and it would return the Ban value.
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
03 | local Banlist = DataStoreService:GetDataStore( "Banlist" ) |
06 | function BanPlayer(Player) |
07 | local success, err = pcall ( function () |
08 | Banlist:SetAsync(Player, true ) |
13 | function UnbanPlayer(Player) |
14 | local success, err = pcall ( function () |
15 | Banlist:SetAsync(Player, false ) |
19 | function CheckBan(Player) |
21 | local success, Banned = pcall ( function () |
22 | return Banlist:GetAsync(Player) |
Basically, Ban and Unban functions basically go to the Player value within Banlist and set it to true or false. CheckBan would check if a player is banned or not.
The script I made here isn't the best but it's to give you the concept.
You should always use the Player's userId and NOT the username, since usernames can be changed, but UserIDs never change. Basically, something like BanPlayer(userId)
I'm not the best at scripting but I hope i've helped you.
I suggest you visit this article I quoted at first.