I am making a "ban" admin command

I am trying to make a ban admin command so an admin could type out :ban user and then it would kick them from the server and if they try to rejoin, they will get kicked. I don’t want to make it a permanent ban so I am trying to avoid using data stores.

I know how to sort the player id for the banned players, but how would I tie on a ban reason so the admin could type out :ban user for hacking and it would tie that reason onto that selected player in a table for example?

I have searched through the dev forum but I can’t find anything related to this, if you have any questions, I can elaborate.

To do this, if you want to make it for a specific server, make a datastore and set the player to ban with a key like "ServerBan_"..game.JobId for the specific and set the key to true when you make the ban and when the player joins, check if their key (using GetAsync) is true and than kick them, likewise for PermBan on all servers, just make a key (PermBan) and set it to true with ban command and get the key when the player joins and check if they are banned (the key is true) and than kick them, for timed bans, make an os.time() for the time to be banned for and set the key to true, and set it back to false when the time is greater than or equal to the time to get unbanned


Thanks a lot, I completely forget about using a data store key, and thanks for giving me the idea of a time ban :grinning:

not really, just use a table, no need to flood datastore, since servers dissappear

How would I go about adding on a reason to each unique player so the admin can see a custom ban reason by using a table?

What I’d do is put the messages in a table, each word has its own place.
Check if arg[1] is :ban, check arg[2] is a player and arg[3] the reason.

1 Like

Add a folder and insert values containing the names of the banned players? Then loop through when someone joins and check if they match the ban. This is server-specific, doesn’t use data stores and I find it is a little bit easier to understand than tables. Use for i, v in pairs(folder:GetChilren()) do if v.Value == (PlayerID) —kick player end end

1 Like

Probably should of thought of that,

thanks everyone who contributed :grinning: