I’ve made a simple ban module!
Here’s how to get it:
local Restrictly = require(6530046094)
There are currently two commands:
Restrictly.Ban(Player.Name, Reason)
-- Reason becomes "Unspecified Reason" if left blank
and
Restrictly.Unban(Player.Name)
This works with in-game and non in-game players!
Example ban:
local Restrictly = require(6530046094)
Restrictly.Ban("THECOOLGENERATOR", "Exploiting")
Aside from this, the module can also be easily implemented in things such as Admin Panels, and anything else! (In fact, it was originally designed for this purpose too!)
Well there is a use. It saves the data and it keeps the player banned, aka not joining. Kick only removes them from the game once. When I said “for ingame players” i meant the player has to be playing the game to be banned.
Alright I’m peeking the source for this since I’m curious as to what you’re doing here.
First of all, I think you should document the data store names you’re using (at the time of writing it’s BanData and ReasonData). You’re hiding this from the user (read: other developers using this module), which is unsafe in the event the user wants to use these data stores for their own use.
Second,
function module.Ban(Player, Reason)
if game.Players:FindFirstChild(Player) then
print("Player found! - "..Player)
for _, Plr in pairs(game.Players:GetPlayers()) do
-- etc.
Not sure why you’re printing “Player found!” when the player has not actually been found yet…
Third,
Bans:SetAsync(Plr.UserId.."-banned", "True")
WHAT on earth are you doing using a string "True" instead of just the boolean value true? This is horrible for efficiency.
Fourth, I don’t know why you’re using two separate data stores for this. You’re using two data store calls for what’s effectively one write operation for the user for no good reason. You should store the ban data in a table, then store that one table in the data store instead, e.g.:
local data = {
banned = true, -- boolean
reason = nil -- Use nil to express no reason, else a string
}
Bans:SetAsync(Plr.UserId, data)
Same amount of information stored for one less data store call. Additionally, you can be more memory-efficient if you just assume nil for the reason member is used to represent an unspecified reason instead of writing "Unspecified reason" to the data store.
Firstly,
it uses if game.Players:FindFirstChild() and so it prints “Player Found!”
Also, if I leave the reason blank, all it will say is: “You were kicked from this game”. I want it to display the “You were banned”
thanks for the other advice, will look into it
I don’t see how this is any different from any other ban modules. It seems that this one is very limited in what you are able to do, making this completely useless. Also, it appears you are making unneccisary data store calls. And y our datastore solution is inefficient.
I am not trying to go off topic but I don’t see a lot of advantages of using this system. Like, a simple ban and unban system in my administration system i s only around 10-15 lines. It is not even hard to implement that, as it is only some simple Get/Set calls.
Unless this has a significant improvement in terms of performance, then this system would be beneficial, but now, no.