Right so, I need help with 2 things today both are about the ban system I am making on my admin panel.
#1 When I use the ban button it does not kick you, but if I leave and rejoin I’m banned. So I have to have it so when you push the ban button it also kicks you.
#2 I have no idea how to code the UnBan button, I know the end goal is to remove the UserId from the ban DataStore.
Heres the ban system code.
NOTE THE WHITELIST FOR THE ADMIN PANEL IS BUILT INTO THE BAN SERVER SCRIPT, DO NOT MIND THAT.
LocalScript. It fires the server
local button = script.Parent
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Ban:FireServer(script.Parent.Parent.Parent.upper.Target.Text, script.Parent.Parent.Parent.upper.Reason.Text)
script.Parent.Parent.Parent.upper.TextLabel.Text = "Player banned."
script.Parent.Parent.Parent.upper.TextLabel.TextTransparency = 0
wait(3)
script.Parent.Parent.Parent.upper.TextLabel.Text = "Teleport failed, please try entering the username again."
script.Parent.Parent.Parent.upper.TextLabel.TextTransparency = 1
end)
Heres the main server script with the built in whitelist.
local configModule = require(script.Admin.panel.Config)
local data = game:GetService("DataStoreService"):GetDataStore(configModule.DataStoreKey)
local configModule = require(script.Admin.panel.Config)
local admins = configModule.adminIDs
local BanMsg = "You have been permenantly banned from this game."
game.Players.PlayerAdded:Connect(function(player)
for _, adminId in pairs(admins) do
if player.UserId == adminId then
local cloneUI = script.Admin:Clone()
cloneUI.Parent = player.PlayerGui
break
end
end
local prevData = data:GetAsync(player.UserId)
if prevData == nil then
print("Player does not have to be banned!")
prevData:SetAsync(player.UserId, false)
elseif prevData == true then
print("Player is banned.")
player:Kick(BanMsg)
end
end)
game.ReplicatedStorage.Ban.OnServerEvent:Connect(function(player, victim, reason)
local found = game.Players:FindFirstChild(victim)
if found then
data:SetAsync(player.UserId, true) -- that inserts the player ban to DataStore
found:Kick(data..' '..reason)
end
end)
Please help, it would be very appreciated