织梦CMS - 轻松建站从此开始!

欧博ABG-会员注册-官网网址

How to use the new Ban API (with code examples)

时间:2025-10-31 16:43来源: 作者:admin 点击: 7 次
Here is a brief summary of how to use roblox’s new ban API. This does not cover everything but it does cover how you could set up a simple system insi

local whitelistTable = {user id here} --Add your User ID here

game.Players.PlayerAdded:Connect(function(plr)
if table.find(whitelistTable,plr.UserId) then
plr.Chatted:Connect(function(msg)
if string.find(msg, "!ban ") then
local splitMessage = string.split(msg, " ")

local userName = splitMessage[2] local banMessage = string.gsub(msg, "!ban "..userName.." ","") local userId = game.Players:GetUserIdFromNameAsync(userName) if userId then game.Players:BanAsync({ UserIds = {userId}, ApplyToUniverse = true, Duration = -1, DisplayReason = banMessage, PrivateReason = banMessage, ExcludeAltAccounts = false, }) end elseif string.find(msg, "!unban ") then local splitMessage = string.split(msg, " ") local userName = splitMessage[2] local userId = game.Players:GetUserIdFromNameAsync(userName) if userId then game.Players:UnbanAsync({ UserIds = {userId}, ApplyToUniverse = true, }) end end end) end

end)

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-11-03 02:11 最后登录:2025-11-03 02:11
栏目列表
推荐内容