How to do a ban system with DataStore

Hello there! I would like feedbacks on how to make a ban system with DataStores?

Providing an example is appreciated.

SOLUTION:

1 Like

You insert the player’s name in a datastore and then make another datastore with a tick value on when the player will be unbanned.

If the current tick value is greater than the datastore tick value, the player is unbanned and can be removed from the datastore.

You can store a table that contains a list of all the players that are banned and save that table to a specific unique key. Then On PlayerAdded you can check if that player is contained in the list

I am trying to make it without tables unless you show me a example.

You can make a datastore that when a player is banned, it sets a key in the datastore with their userid and sets the value to true. If a player joins, it checks if they have a key in that datastore with their userid and if they do and the value is true, kick them again since they are banned. And to unban, just set their key’s value to false

How would I setup the key however?

The key is literally their userid, when you ban someone, get their user id, use SetAsync, giving the userid as the first thing and true as the 2nd thing to put true into their userid key.

When they join, the game checks if they have a key in the datastore with their userid, if they do and the value in that key is true, kick them again

That confuses me. If you could give me a example.

DataStore:SetAsync(useridtoban,true)

Where DataStore is the varaible containing your Datastore for banned users and useridtoban being the userid of the user you want to ban