**testing out a custom admin panel, ban script works but unban script doesn’t, can anyone please help **
local banDS = game:GetService("DataStoreService"):GetDataStore("Bans")
local mods = {900293979}
game:GetService("Players").PlayerAdded:Connect(function(plr)
local key = "-Banned" ..plr.UserId
local success, val = pcall(function()
return banDS:GetAsync(key)
end)
if(success) then
if(val) then
if(val[2] == true) then
plr:Kick("\n You are permenetly banned. \n Reason: \n" .. val[1])
end
end
else
print("An error occured while checking" .. plr.UserId .. " " .. plr.Name)
warn(val)
end
end)
game:GetService("ReplicatedStorage").BanRequest.OnServerEvent:Connect(function(mod, plr, reason)
if (table.find(mods, mod.UserId)) then
if(reason ~= false) then
local key = "-Banned" .. plr.UserId
local success, err = pcall(function()
banDS:SetAsync(key,{reason, true})
end)
plr:Kick("\n You are permenetly banned. \n Reason: \n" .. reason)
else
local success, err = pcall(function()
banDS:RemoveAsync("-Banned" .. plr.UserId)
end)
if (not success) then
print("unable to unban".. plr.Name .. "UserId: " .. plr.UserId)
warn(err)
end
end
end
end)
local BanDS = game:GetService("DataStoreService"):GetDataStore("Bans")
BanDS:SetAsync("-Banned" ..308764396, nil) -- If you're using another account change the id for that one
local banDS2 = game:GetService("DataStoreService"):GetDataStore("unBans")
game:GetService("ReplicatedStorage").BanRequest.OnServerEvent:Connect(function(mod, plr, reason)
if (table.find(mods, mod.UserId)) then
if(reason ~= false) then
local key = "-Banned" .. plr.UserId
local success, err = pcall(function()
banDS2:SetAsync(key,{reason, true})
end)
plr:Kick("\n You are permenetly banned. \n Reason: \n" .. reason)
else
local success, err = pcall(function()
banDS2:RemoveAsync("-Banned" .. plr.UserId)
end)
if (not success) then
print("unable to unban".. plr.Name .. "UserId: " .. plr.UserId)
warn(err)
end
end
end
end)
tried that, still didnt work. did I do something wrong?
“bans” is the name of the datastore with your userid banned within its data. If you change the script to look for a datastore named “bans2” it will generate a new datastore with nothing in it.
This was @shipmaster2410 's idea, i’d give him the solution.