So, I don’t really know the problem, but I will give you some information on what I did for my admin system, which may not be perfect but it works.
I like your code, but from my experience with BaseAdmin, this is what I coded for unbanning, if it detects the rank is ‘-1’
if rank==-1 then
local banData
pcall(function()banData = var.data2:GetAsync("_Ban"..plr.UserId)end)
if not banData or not banData.time then
local msg = ""
local canChat = game.Chat:CanUserChatAsync(plr.UserId)
if canChat then
plr.Chatted:Connect(function(m)msg = m end)
else
local gui = script.GUI.BaseGui:Clone()
local yesNo = script.GUI.Addons.YesNo:Clone()
yesNo.Parent = gui.Frame.Window
local click = script.GUI.Addons.ClickEvent:Clone()
click.Parent = gui.Frame.Window
click.Clicked.OnServerEvent:Connect(function(_, m)
msg=m
end)
local desc = script.GUI.Addons.DescText:Clone()
desc.Text = "PLEASE READ BEFORE ENTERING IN AN OPTION!\nYou may close this window after you have entered in an option. If you've already selected an option, you may change it by clicking another option."
desc.Parent = gui.Frame.Window
gui.Frame.Position = UDim2.fromScale(0, 1)
gui.Frame.AnchorPoint = Vector2.new(0, 1)
gui.DisplayOrder=9999
gui.ResetOnSpawn = false
gui.Frame.TitleBar.Text = "Would you like BaseAdmin to fix this problem?"
gui.Parent = plr.PlayerGui
end
delay(5, function()
plr.CharacterAdded:Connect(function()
plr.Character:Destroy()
end)
plr:LoadCharacter()
end)
local mgui = notifyplayersystemmessage("BaseAdmin: join error 3.\n\n❌\n\nMore information:\nBaseAdmin cannot find your BanData! You can still play this game, but your rank will be reset.\n\nIf you wish to stay banned and rather contact an administrator, chat n\n\nIf you want to have your Admin rank reset, chat y.\n\nNote:\nIf you have chosen to reset your rank, you will be kicked and asked to rejoin to apply the changes.\nIf you have a VIP rank, group rank, gamepass rank, setup rank, or rank that was not set by admin, you may automatically obtain it after rejoining.\n\nChat within 45 seconds or you will be kicked! After chatting you must wait up to 45 seconds.\n\nWhy we can't get your rank back?\nBanData contains your previous rank. Your rank was set to -1 (banned) when you were banned, and BanData contains documentation on what your previous rank used to be.\nWe cannot find BanData, and your current rank is -1.\n\nIf you don't have chat, please use the yes/no options in the dialog box.", plr.Name, 60, 'e')
local timeleft = 45
while timeleft>0 do
timeleft-=wait(1)
end
notifyplayersystemmessage("BaseAdmin is processing your request. BaseAdmin will tell you the result of your request in 10 seconds.", plr.Name, 90, 'e')
wait(10)
local gui = notifyplayersystemmessage("BaseAdmin BanSolver\n\nIf there is no foreground window, report this problem to SubtotalAnt8185.", plr, 999) do
gui.BackgroundTransparency = 0
end
if msg == 'y' or msg=='yes' then
local s, e = nil
if var.data2 then
s, e = pcall(var.data2.RemoveAsync, var.data2, plr.UserId)
end
if not e then
e = "DEBUG and/or DataStore disabled."
end
if not s then
msg = "BaseAdmin Ranking Error.\n❌\nWe're sorry for the inconvenience, but there's an error involving your ban rank.\nBaseAdmin couldn't rank you to 0 (non admin), so you will continue to be ranked -1 (banned).\nThis will result in you not becoming unbanned.\nThis error is rare, and to potentially fix it please contact support in the group wall (search up SubtotalAnt8185 in groups).\nThis inconvenience may be caused by an interference from another datastore system, BaseAdmin's loader being outdated, or a Roblox service outage.\nPlease respond soon as this fault doesn't happen often, and we want feedback from it. If you can, send this information:\n"..e.."\n\nIf the error message is related to DEBUG, please contact the developer."
else
msg = "Successful! BaseAdmin has unranked your banned rank! Please rejoin to play the game like a non-admin."
end
local gui = script.GUI.BaseGui:Clone() do
gui.DisplayOrder = 500
local desc = script.GUI.Addons.DescText:Clone()
desc.Text = "Would you like to view the output in a SystemMessage? Selecting 'No' will exit the game. Selecting 'Yes' will display a larger message, ideal for mobile users. If you select 'Yes', the message will close automatically after 120 seconds.\n\nNote: After pressing 'yes', you may press 'no' to leave the game, this window will not close but you may minimize it."..((s==true and "\n\nWe hope you enjoyed BaseAdmin's BanResolver!") or "\n\nIf you encounter issues, it might just help to try again later.")
desc.Parent = gui.Frame.Window
local yesNo = script.GUI.Addons.YesNo:Clone()
yesNo.Parent = gui.Frame.Window
local clickEvent = script.GUI.Addons.ClickEvent:Clone()
clickEvent.Parent = gui.Frame.Window
gui.Frame.TitleBarButtons.close:Destroy()
gui.Parent = plr.PlayerGui
clickEvent.Clicked.OnServerEvent:Connect(function(_, option)
if option == 'yes' then
notifyplayersystemmessage(msg, plr, 9999, 'e')
wait(120)
plr:Kick(msg)
else
plr:Kick(msg)
end
gui:Destroy()
end)
end
return
end
if msg ~= 'n' and msg ~= "no" then
plr:Kick("BaseAdmin: join error 3. If you rejoin, BaseAdmin may give you a list of options to work around this error."..genericV.genericErrorMsg)
return
end
end
local msg = banData.message
local time = banData.time
local originalRank = banData.rank
if time<tick() then
plr.BaseAdminPlayerData.SetRank.Value = originalRank
local s, e = pcall(var.data2.RemoveAsync, var.data2, "_Ban"..plr.UserId)
local unbanMessage = banData.unbanMessage or 'Unbanned by BaseAdmin'
local s2, e2 = pcall(function()
local dd = var.data2:GetAsync("_Bans")
local new = http:JSONDecode(dd)
local i = tostring(plr.UserId)
local v = new[i]
v.previousBans[time]='Ban: '..v.status..' Original ban message: '..msg..' Unban message: '..unbanMessage
v.message = 'PreviousBans for '..plr.Name
v.status = "not banned"
new[i] = v
new = http:JSONEncode(new)
var.data2:SetAsync("_Bans", new)
repeat wait(2) until var.data2:GetAsync("_Bans")==new
end)
if not s2 then
warn(e2)
notifyplayersystemmessage("Warning:\nBaseAdmin has failed to clear your name from the BanLogs!\nThis means if someone looks in BanLogs, they may still see your name as if you were still banned!\nYou may be able to fix this issue by using the unban command.\nIf the error persists, inform SubtotalAnt8185 about this issue:\n\n"..e2.."\n\nNote: This error may be caused by Roblox issues. If you are in a roleplay game and users check banlogs, it may not be a bad idea to screenshot this and save it (Hint: press Print Screen once or press F12 twice. On Android phones, press the volume and power buttons at the same time to take a screenshot).\n\nThis message will close in 30 seconds.\n\nPossible Fixes:\n1. Rejoin\n2. Leave and try again later\n3. Ask a developer about this issue", plr.Name, 30, 'e')
wait(30)
end
if not s then
warn('cannot remove ban '..e)
notifyplayersystemmessage("Unban Error 1\n❌\nBaseAdmin: Error removing ban! Contact an admin.\nIt appears the datastore is locked or currently unavailable.\nPlease try again later.\n\nIf you wish to contact a developer or SubtotalAnt8185 to fix this issue, send the data below:\n\n"..e, plr.Name, 10, 'e')
else
notifyplayersystemmessage("You have been unbanned.\n✅\nBaseAdmin requires you to rejoin to use commands. Chat 'no' to cancel.\nUnban message:\n"..unbanMessage, plr.Name, 10, true)
end
local saidNo
saidNo = plr.Chatted:Connect(function(msg)
if msg:lower()=='no' or msg:lower()=="'no'" or msg:lower()=="n" then
saidNo:Disconnect()
saidNo = nil
notifyplayersystemmessage("The automatic rejoin operation was stopped.", plr.Name, 5, "push-notification2")
end
end)
wait(10)
if saidNo then
saidNo:Disconnect()
pcall(tele.Teleport, tele, game.PlaceId, plr)
wait(5)
notifyplayersystemmessage('Rejoin failed.\n❌\nPlease exit the game and manually rejoin.\nIf this is a possible issue, ask the developer to enable third party teleports.', plr.Name, 5, 'e')
wait(5)
plr:Destroy()
return
end
end
wait(1.5)
local b = "You are banned. Contact an admin with an unbanning ability to get unbanned.\n\nThe ban message does not exist, this is a fallback message. The ban might not have been initiated correctly.\nIf this is an issue, you must contact a developer."
if msg then
b = msg
end
b = "BaseAdmin:\n"..b
local bantext = {
'❌',
'⛔',
'🚫',
'⭕',
'❎',
'❓',
'📛',
'🛑',
'❗',
'🔴'
}
local hrs = (time-tick())/86400
local bt = "The number of symbols will indicate the days you have left on your ban.\n"
for i = 1, hrs/3 do
bt..=bantext[math.random(1, #bantext)]
end
if config.SecureKick then
plr:Kick(b.."\nHoursLeft:"..math.floor(hrs).."\nSecureKick is currently enabled.")
return
end
bt..='\n<font size="7"><font color="rgb(60, 60, 60)">Hours left: '..math.floor(hrs)..'</font></font>'
local txt, gui = notifyplayersystemmessage(bt, plr.Name, 100, 'e')
gui.ResetOnSpawn = false
local s = script.lg:Clone()
s.Parent = gui
plr.Character:Destroy()
wait(20)
plr:Kick(b)
return
end
You might be thinking how can I understand all of this!? which is why I’m here.
Basically, the simple thing it does is detects for this thing called BanData
. BanData
is documentation on the previous rank and the time the player should be unbanned.
Based on this, there’s only one thing that’s wrong with my code. The ban time can be different based on the server local time.
So, unlike doing this:
I did this:
t.unban = {function(Player, plr, ...)
local msg = getFilteredMessage(Player, ...)
local bmsg = ' unbanned by '..Player.Name..(msg or "")
local userId = game.Players:GetUserIdFromNameAsync(plr)
if userId then
local banData = datastore:GetAsync("_Ban"..userId)
if banData then
datastore:SetAsync("_Ban"..userId, {
message = banData.message,
unbanMessage = bmsg,
time = 0,
rank = banData.rank
})
local new = {}
for id, v in pairs(http:JSONDecode(datastore:GetAsync("_Bans"))) do
if id==userId then
v.status = "pending unban from "..Player.Name
v.message..= bmsg
end
new[id]=v
end
datastore:SetAsync("_Bans", http:JSONEncode(new))
notify("✅", Player.Name, 1, true)
else
notify("This player isn't banned!", Player.Name, 3, 'e')
end
end
end, 'Unbans the target player.', '<plr>', 5}
For unbanning.
Unfortunately, I didn’t have any luck with tables, so I used JSON instead.
The “_bans” datastore contains all bans. Don’t worry about that.
The “_Ban” datastore contains the BanData
. That thing I was talking about earlier. What this does is sets the time to 0 so the user is no longer banned when they join again, since the script will look if the local time is greater or less than the ban time.
I know this is lots of information to digest, but I think this is a more detailed explanation of what BaseAdmin does. And it does work, so if you’re willing to try a method like this and it works, that’s good for you.