My custom admin GUI’s unban function does not work.
The ban/unban system works on tables
I have tried numerous methods, All have failed.
Current script:
Script
remoteEvent2.OnServerEvent:Connect(function(player, Username, Reason, Type)
local UserId = game.Players:GetUserIdFromNameAsync(Username)
if table.find(Allowed, player.UserId) then
if game.Players:FindFirstChild(Username) and Type == "Kick" then
game.Players:FindFirstChild(Username):Kick(Reason)
elseif game.Players:FindFirstChild(Username) and Type=="Ban" then
table.insert(Banned, game.Players:FindFirstChild(Username).UserId)
game.Players:FindFirstChild(Username):Kick("You have been banned from this server. Reason: "..Reason)
elseif game.Players:FindFirstChild(Username) and Type=="Unban" then
local success, failure = pcall(function()
table.remove(Banned, UserId)
end)
if success then
remoteEvent4:FireClient(player, "Unban System","Unban successful!", 7.5)
else
remoteEvent4:FireClient(player, "Unban System","Unban failed! User was not found.", 7.5)
end
end
elseif not table.find(Allowed, player.UserId) then
table.insert(Banned, player.UserId)
if Type=="Kick" then
player:Kick("nice try "..Type.."ing someone ya big exploiter")
Reason="Exploiting"
else
player:Kick("nice try "..Type.."ning someone ya big exploiter")
Reason="Exploiting"
end
end
serverbanreason=Reason
end)
How is this list of banned users being saved? If it’s hardcoded, it won’t work because it will be removed, but won’t save for new servers or any other server.
Its a serverban, so its an empty table at first
then a userid is inserted via table.insert
and with the unban it will remove the user id of the user that is banned
but i have found no fix for it yet
remoteEvent2.OnServerEvent:Connect(function(player, Username, Reason, Type)
local UserId = game.Players:GetUserIdFromNameAsync(Username)
if table.find(Allowed, player.UserId) then
if game.Players:FindFirstChild(Username) and Type == "Kick" then
game.Players:FindFirstChild(Username):Kick(Reason)
elseif game.Players:FindFirstChild(Username) and Type=="Ban" then
table.insert(Banned, game.Players:FindFirstChild(Username).UserId)
game.Players:FindFirstChild(Username):Kick("You have been banned from this server. Reason: "..Reason)
elseif game.Players:FindFirstChild(Username) and Type=="Unban" then
local success, failure = pcall(function()
if table.find(Banned, UserId) then table.remove(Banned, table.find(Banned, UserId)) end
--table.remove(Banned, table.find(Banned, UserId))
end)
if success then
remoteEvent4:FireClient(player, "Unban System","Unban successful!", 7.5)
else
remoteEvent4:FireClient(player, "Unban System","Unban failed! User was not found.", 7.5)
end
end
elseif not table.find(Allowed, player.UserId) then
table.insert(Banned, player.UserId)
if Type=="Kick" then
player:Kick("nice try "..Type.."ing someone ya big exploiter")
Reason="Exploiting"
else
player:Kick("nice try "..Type.."ning someone ya big exploiter")
Reason="Exploiting"
end
end
serverbanreason=Reason
end)