Ban system I cannot do

Hey guys i cannot make the ban system can you guy’s help me?

local target = script.Parent.Parent.user
local reason = script.Parent.Parent.reason
local remote = game.ReplicatedStorage.Folder
script.Parent.MouseButton1Click:Connect(function ()
	remote.ban:FireServer(target.Text,reason.Text)
end)
local bandata = game:GetService("DataStoreService"):GetDataStore("Ban")
local admins = {
	["dr12lol"] = 1;
}
local Banmessage = "You are banned."
game.Players.PlayerAdded:Connect(function(player)
	if admins[player.Name] then
		local clone = script.admin:Clone()
		clone.Parent = game.StarterGui	
	end
	local perviousdata = bandata:GetAsync(player.UserId)
	if perviousdata == nil then
		print("the player is not banned Ok?")
		perviousdata:SetAsync(player.Id, false)
	elseif perviousdata == true then
		print("Player is banned. So kicked him.")
		player:Kick(Banmessage, " ")
	end
	
end)

game.ReplicatedStorage.Folder.kick.OnServerEvent:Connect(function (Player,user, reason)
	if Player.UserId == 2636827348 then
		game.Players:FindFirstChild(user):Kick(reason)
	end
end)
game.ReplicatedStorage.Folder.ban.OnServerEvent:Connect(function(player,user,reason)
	local found = game.Players:FindFirstChild(user)
	if found then
		bandata:SetAsync(player.UserId,true)
		found:Kick(Banmessage..reason)
	end
end)
1 Like

Hey, try this ban system.

Global Ban Script.lua (2,4 KB)

It has a global feature, and checks if the person who bans is a admin, in case if it is not an exploiter.

you used player.UserId instead of found.UserId

essentially it bans the admin that executed the command.

1 Like

Also you need to confirm it’s an admin that is firing to the server and not a hacker. (check player if they are admin) and then ban found if found.

hey i kinda do not like to use anti cheat since this is a solo game. But fine?

Hey i loved you’re script do you want to be A developer on my game???