I need help making a ban script

A simple ban script I came up with is this. (It uses remotes)

local prefix, ds, banstore = "user_", game:GetService("DataStoreService"), ds:GetDataStore("Bans")

local plr = Player
local p = Mod
		local args = {}
		args.reason = "Reason here (Presumably sent with the remote)"
		args.plr = plr
		banStore:SetAsync(prefix.. tostring(plr.UserId), {
			true--[[if they are banned]]--, 
            args.msg--[[Reason]]--, 
            p.Name --[[Person who banned them]]---
		})
		plr:Kick('You have been banned by: '..p.Name..' for: '..args.msg)
	end

And Like wise with unban (same thing but I just skipped all of that other stuff)

		banStore:SetAsync(prefix.. tostring(pid), {
			false, "", ""
		})
		log(data)
	end

And then you need to check on join.

game.Players.PlayerAdded:Connect(function(plr)
local plrData = banStore:GetAsync(prefix.. tostring(plr.UserId) --Fetching data
if plrData[1] == true then 
--[[1 is the value that says if it is true or not]]--
Kick('You have been banned by: '..p.Name..' for: '..args.msg)
end)

And that’s a complete set for your ban. Put it in ServerScriptService or else it won’t work.

Good luck and happy scripting. :smiley:

3 Likes