You would modify the Server Script to look like this (assuming DataStore setup):
-- (Inside the OnServerEvent connection, after confirming admin status)
local DataStoreService = game:GetService("DataStoreService")
local BanDataStore = DataStoreService:GetDataStore("BanData")
-- ... (Inside the event connection)
local targetUserId = Players:GetUserIdFromNameAsync(targetPlayerName) -- Get ID from name
-- Save to DataStore
local success, err = pcall(function()
BanDataStore:SetAsync("Ban_" .. targetUserId, true)
end)
if success then
-- Kick them immediately to enforce the ban
targetPlayer:Kick("You have been permanently banned from this game.")
else
warn("Failed to ban player due to DataStore error.")
end
Below is a functional example of how to set up a secure Kick system. This requires two scripts: one Server Script and one LocalScript (often used in a GUI or Chat Command system). FE Ban Kick Script - ROBLOX SCRIPTS - FE Admin ...
It is important to distinguish between the two actions: You would modify the Server Script to look