I am trying to make a ban system where if you are banned using the ;ban command you are teleported to a separate game whenever you try to join the main game.
I would appreciate it if anyone could let me know of any sources I could use or some help.
I have tried looking through tutorials, developer forum and everything else I know of and can’t seem to find it.
If anything doesn’t make sense, please let me know.
You could use the player.Chatted method, a table, and TeleportService. When the player (an admin) chats “;ban NoobGuy”, it would find the player named “NoobGuy”, add the player to a table, save the table as a DataStore, and teleport the player to Banland.
That would work perfectly. Take a look at these links for more help!
These should help you with this Tables - Insert a new value (player name) when the command is ran. Player Chatted - Check if the message once this is fired. Saving Tables - Save the table once the ;ban command is ran Teleport service - You will use this to teleport the player to the separate game if banned. Find values in a table - Used for checking if the player’s name is in the table.
Hope I helped! If you need more assistance don’t be afraid to ask.
To execute chat commands you’d have to use the Player.Chatted event function.
To teleport visitors to another experience such as a ban land you’d use the TeleportService.
To read and write data scopes and values you’d use DataStoreService.
In order to send messages in the chat from the Roblox system to view status of commands, you’d use StarterGui:SetCore() function (LOCALLY, this is not used in this example, prints are used as an improvisation)
In order to set a list of administrators, you’d use a Table.
Some code I quickly wrote up utilizing the APIs:
local Players = game:GetService("Players")
local DataStoreService = game:GetService('DataStoreService')
local savedBanData = DataStoreService:GetDataStore('SavedBans')
local TeleportService = game:GetService('TeleportService')
local Administrators = {448443585, 123456789,} -- UserIDs of your admins
local BanLandGameID = 123456789 -- Replace with your banland's game/experience ID
local placeBanCmd = ";pban " -- place ban (pban)
local removeBanCmd = ";rban " -- remove ban (rban)
Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:Wait()
if savedBanData:GetAsync(plr.UserId) then
TeleportService:Teleport(BanLandGameID,plr)
end
plr.Chatted:connect(function(message)
local authorised = false
if table.find(Administrators,plr.UserId) then
authorised = true
end
if not authorised then return end
if message:sub(1, placeBanCmd:len()):lower() == placeBanCmd:lower() then
local name = message:sub(placeBanCmd:len() + 1)
local playerToBan = Players:GetUserIdFromNameAsync(name)
if playerToBan and table.find(Administrators,playerToBan) then
print'Cannot use command on administrators'
-- Cannot use command on administrators
return
end
local playerToBan = Players:GetUserIdFromNameAsync(name)
if playerToBan then
savedBanData:SetAsync(playerToBan,true)
print'Successfully banned player'
-- Successfully banned player
else
print'Invalid player'
-- Invalid player
end
elseif message:sub(1, removeBanCmd:len()):lower() == removeBanCmd:lower() then
local name = message:sub(removeBanCmd:len() + 1)
local playerToUnBan = Players:GetUserIdFromNameAsync(name)
if playerToUnBan then
savedBanData:RemoveAsync(playerToUnBan)
print'Successfully unbanned player'
-- Successfully unbanned player
else
print'Invalid player'
-- Invalid player
end
end
end)
end)