Thanks! To upgrade your admin system with cross-server announcements, logging, better targeting, and balanced NPC spawning, I just need to clarify a few quick things:
🔄 For cross-server announcements, do you already have MessagingService enabled in Studio under Home > Game Settings > Security?
💾 For logging admin commands (ban, kick, etc.), should I store them in a DataStore, MemoryStore, or just keep a history in ReplicatedStorage?
🎯 For targeting players: should partial name matches be allowed even if multiple users have similar names? (e.g., "rob" matches "roblx123" and "robro")
⚖️ For NPCs: Would you like the chance system to be based on percentages (adding up to 100%) or weights (e.g., 10, 90, 50 — relative odds)?
🛠️ About /panel and F4 — what admin module or UI system are you using (e.g., HD Admin, custom GUI)?
Once I know this, I’ll deliver the full upgrade. Let’s make it powerful and fair!
YES!!!!
make this work!!
--// Admin Command Module (Revamped & Optimized)
-- Place this as a ModuleScript in ServerScriptService
local module = {}
local Players = game:GetService("Players")
local UserService = game:GetService("UserService")
local InsertService = game:GetService("InsertService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AdminRemotes = ReplicatedStorage:WaitForChild("AdminRemotes").Utility
local BannedUsersRemote = AdminRemotes.BannedUsers
local AnnouncementRemote = AdminRemotes.Announcement
--// Ban
module["Ban"] = function(args, admin, bandatastore)
local PlayerName, Reason = args.Player, args.Reason or "Banned by admin"
local AdminName = admin and admin.Name or "Server"
if PlayerName == AdminName then return "You cannot ban yourself." end
code
local userId = UserService:GetUserIdFromNameAsync(PlayerName)
if not userId then return "Invalid user." end
local bannedList = bandatastore:GetAsync("banned") or {}
if table.find(bannedList, tostring(userId)) then return "User already banned." end
table.insert(bannedList, tostring(userId))
bandatastore:SetAsync("banned", bannedList)
for _, plr in ipairs(Players:GetPlayers()) do
if plr.UserId == userId then
plr:Kick(Reason)
break
end
end
BannedUsersRemote:FireAllClients(bannedList)
return "✅ Banned " .. PlayerName
end
--// Unban
module["Unban"] = function(args, admin, bandatastore)
local PlayerName = args.Player
local userId = UserService:GetUserIdFromNameAsync(PlayerName)
if not userId then return "Invalid user." end
code
local bannedList = bandatastore:GetAsync("banned") or {}
for i, id in ipairs(bannedList) do
if id == tostring(userId) then
table.remove(bannedList, i)
bandatastore:SetAsync("banned", bannedList)
BannedUsersRemote:FireAllClients(bannedList, PlayerName)
return "✅ Unbanned " .. PlayerName
end
end
return "User not found in ban list."
end
--// Announcement (Global)
module["Announce"] = function(args, admin)
local Message = args.Message
if Message and #Message > 0 then
AnnouncementRemote:FireAllClients(Message)
return "✅ Announcement sent"
else
return "Please enter a valid message."
end
end
--// Kick
module["Kick"] = function(args, admin)
local PlayerName, Reason = args.Player, args.Reason or "Kicked by admin"
if PlayerName == admin.Name then return "You cannot kick yourself." end
local target = Players:FindFirstChild(PlayerName)
if target then
target:Kick(Reason)
return "✅ Kicked " .. PlayerName
else
return "Player not found."
end
end
--// Shutdown
module["Shutdown Server"] = function(args, admin)
for _, plr in ipairs(Players:GetPlayers()) do
plr:Kick("Server shutting down.")
end
return "✅ Server is shutting down."
end
--// Fly
module["Fly"] = function(args, admin)
local PlayerName = args.Player
local target = Players:FindFirstChild(PlayerName)
if not target or not target.Character then return "Player not found." end
local hrp = target.Character:FindFirstChild("HumanoidRootPart")
if not hrp then return "Missing HumanoidRootPart." end
module["Unfly"] = function(args, admin)
local PlayerName = args.Player
local target = Players:FindFirstChild(PlayerName)
if not target or not target.Character then return "Player not found." end
local hrp = target.Character:FindFirstChild("HumanoidRootPart")
if hrp then
local fly = hrp:FindFirstChild("FlyVelocity")
if fly then fly:Destroy() end
return "✅ " .. PlayerName .. " stopped flying"
end
return "No fly state found."
end
--// Kill
module["Kill"] = function(args, admin)
local PlayerName = args.Player
local target = Players:FindFirstChild(PlayerName)
if target and target.Character then
target.Character:BreakJoints()
return "✅ Killed " .. PlayerName
end
return "Player not found."
end
--// Speed
module["Speed"] = function(args, admin)
local PlayerName, Value = args.Player, tonumber(args.Value)
local target = Players:FindFirstChild(PlayerName)
if target and target.Character and Value then
target.Character.Humanoid.WalkSpeed = Value
return "✅ Speed set to " .. Value
end
return "Invalid input."
end
--// Jump
module["Jump"] = function(args, admin)
local PlayerName, Value = args.Player, tonumber(args.Value)
local target = Players:FindFirstChild(PlayerName)
if target and target.Character and Value then
target.Character.Humanoid.JumpPower = Value
return "✅ JumpPower set to " .. Value
end
return "Invalid input."
end
return module
how to make npc's like be able so i can walk through them yk so people can't mess them up and cause glitches in my game!
Assistant
I'll create a complete upgraded admin system with all the features you want! Here's the full implementation:
--// Advanced Admin Command Module (Fully Upgraded)
-- Place this as a ModuleScript in ServerScriptService
local module = {}
local Players = game:GetService("Players")
local UserService = game:GetService("UserService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MessagingService = game:GetService("MessagingService")
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
-- Data Stores
local LogDataStore = DataStoreService:GetDataStore("AdminLogs")
local BanDataStore = DataStoreService:GetDataStore("BannedUsers")
-- Create Admin Remotes if they don't exist
local AdminRemotes = ReplicatedStorage:FindFirstChild("AdminRemotes") or Instance.new("Folder")
AdminRemotes.Name = "AdminRemotes"
AdminRemotes.Parent = ReplicatedStorage
local Utility = AdminRemotes:FindFirstChild("Utility") or Instance.new("Folder")
Utility.Name = "Utility"
Utility.Parent = AdminRemotes
local BannedUsersRemote = Utility:FindFirstChild("BannedUsers") or Instance.new("RemoteEvent")
BannedUsersRemote.Name = "BannedUsers"
BannedUsersRemote.Parent = Utility
local AnnouncementRemote = Utility:FindFirstChild("Announcement") or Instance.new("RemoteEvent")
AnnouncementRemote.Name = "Announcement"
AnnouncementRemote.Parent = Utility
-- Logging function
local function logCommand(command, admin, target, details)
pcall(function()
local timestamp = os.time()
local logEntry = {
Command = command,
Admin = admin and admin.Name or "Server",
AdminId = admin and admin.UserId or 0,
Target = target,
Details = details or "",
Timestamp = timestamp,
Server = game.JobId
}
-- Store in DataStore (with timestamp key for unique entries)
local key = "Log_" .. timestamp .. "_" .. math.random(1000, 9999)
LogDataStore:SetAsync(key, logEntry)
end)
end
-- Enhanced player finding with partial match
local function findPlayer(name, admin)
name = name:lower()
local matches = {}
for _, player in ipairs(Players:GetPlayers()) do
if player.Name:lower():find(name, 1, true) or player.DisplayName:lower():find(name, 1, true) then
table.insert(matches, player)
end
end
if #matches == 1 then
return matches[1]
elseif #matches > 1 then
-- Try exact match first
for _, player in ipairs(matches) do
if player.Name:lower() == name then
return player
end
end
-- Return first match if no exact match
return matches[1]
end
return nil
end
--// Cross-Server Messaging Setup
local function sendCrossServerMessage(messageType, data)
pcall(function()
MessagingService:PublishAsync("AdminSystem", {
Type = messageType,
Data = data,
Server = game.JobId
})
end)
end
-- Subscribe to cross-server messages
pcall(function()
MessagingService:SubscribeAsync("AdminSystem", function(message)
local data = message.Data
if data.Server ~= game.JobId then -- Don't process our own messages
if data.Type == "Announcement" then
AnnouncementRemote:FireAllClients(data.Data.Message)
elseif data.Type == "ServerShutdown" then
for _, plr in ipairs(Players:GetPlayers()) do
plr:Kick("All servers shutting down: " .. (data.Data.Reason or "Admin shutdown"))
end
end
end
end)
end)
--// Ban (Improved)
module["Ban"] = function(args, admin, bandatastore)
local PlayerName, Reason = args.Player, args.Reason or "Banned by admin"
local AdminName = admin and admin.Name or "Server"
-- Find player with partial match
local targetPlayer = findPlayer(PlayerName)
local actualName = targetPlayer and targetPlayer.Name or PlayerName
if actualName == AdminName then return "You cannot ban yourself." end
local userId
if targetPlayer then
userId = targetPlayer.UserId
else
-- Try to get userId for offline player
local success, result = pcall(function()
return UserService:GetUserIdFromNameAsync(actualName)
end)
if success then
userId = result
else
return "Invalid user."
end
end
local bannedList = BanDataStore:GetAsync("banned") or {}
if table.find(bannedList, tostring(userId)) then return "User already banned." end
table.insert(bannedList, tostring(userId))
BanDataStore:SetAsync("banned", bannedList)
-- Kick if online
if targetPlayer then
targetPlayer:Kick(Reason)
end
-- Log the ban
logCommand("Ban", admin, actualName, Reason)
-- Update all clients
BannedUsersRemote:FireAllClients(bannedList)
return "✅ Banned " .. actualName .. " | Reason: " .. Reason
end
--// Unban (Improved)
module["Unban"] = function(args, admin, bandatastore)
local PlayerName = args.Player
local userId
local success, result = pcall(function()
return UserService:GetUserIdFromNameAsync(PlayerName)
end)
if success then
userId = result
else
return "Invalid user."
end
local bannedList = BanDataStore:GetAsync("banned") or {}
for i, id in ipairs(bannedList) do
if id == tostring(userId) then
table.remove(bannedList, i)
BanDataStore:SetAsync("banned", bannedList)
-- Log the unban
logCommand("Unban", admin, PlayerName)
BannedUsersRemote:FireAllClients(bannedList, PlayerName)
return "✅ Unbanned " .. PlayerName
end
end
return "User not found in ban list."
end
--// Cross-Server Announcement
module["Announce"] = function(args, admin)
local Message = args.Message
local CrossServer = args.CrossServer ~= false -- Default to true
if Message and #Message > 0 then
-- Send to current server
AnnouncementRemote:FireAllClients(Message)
-- Send cross-server if enabled
if CrossServer then
sendCrossServerMessage("Announcement", {Message = Message})
end
-- Log the announcement
logCommand("Announce", admin, "All", Message)
return "✅ Announcement sent" .. (CrossServer and " (all servers)" or " (this server)")
else
return "Please enter a valid message."
end
end
--// Kick (Improved with logging)
module["Kick"] = function(args, admin)
local PlayerName, Reason = args.Player, args.Reason or "Kicked by admin"
if PlayerName == admin.Name then return "You cannot kick yourself." end
local target = findPlayer(PlayerName)
if target then
logCommand("Kick", admin, target.Name, Reason)
target:Kick(Reason)
return "✅ Kicked " .. target.Name
else
return "Player not found."
end
end
--// Shutdown (with cross-server option)
module["Shutdown Server"] = function(args, admin)
local CrossServer = args.CrossServer or false
local Reason = args.Reason or "Server shutting down"
logCommand("Shutdown", admin, CrossServer and "All Servers" or "This Server", Reason)
if CrossServer then
-- Shutdown all servers
sendCrossServerMessage("ServerShutdown", {Reason = Reason})
end
-- Shutdown current server
for _, plr in ipairs(Players:GetPlayers()) do
plr:Kick(Reason)
end
return "✅ " .. (CrossServer and "All servers" or "Server") .. " shutting down."
end
--// View Logs
module["ViewLogs"] = function(args, admin)
local logs = {}
local success, pages = pcall(function()
return LogDataStore:ListKeysAsync()
end)
if success then
while true do
local items = pages:GetCurrentPage()
for _, item in ipairs(items) do
local logData = LogDataStore:GetAsync(item.KeyName)
if logData then
table.insert(logs, logData)
end
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
end
-- Sort by timestamp (newest first)
table.sort(logs, function(a, b)
return a.Timestamp > b.Timestamp
end)
-- Return last 20 logs formatted
local output = "📋 Recent Admin Logs:\n"
for i = 1, math.min(20, #logs) do
local log = logs[i]
output = output .. string.format("[%s] %s used /%s on %s",
os.date("%m/%d %H:%M", log.Timestamp),
log.Admin,
log.Command,
log.Target
) .. "\n"
end
return output
end
--// Existing commands (Fly, Kill, Speed, Jump) remain the same but add logging
module["Fly"] = function(args, admin)
local PlayerName = args.Player
local target = findPlayer(PlayerName)
if not target or not target.Character then return "Player not found." end
local hrp = target.Character:FindFirstChild("HumanoidRootPart")
if not hrp then return "Missing HumanoidRootPart." end
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Name = "FlyVelocity"
bodyVelocity.MaxForce = Vector3.new(0, math.huge, 0)
bodyVelocity.Velocity = Vector3.new(0, 50, 0)
bodyVelocity.Parent = hrp
logCommand("Fly", admin, target.Name)
return "✅ " .. target.Name .. " is flying"
end
module["Unfly"] = function(args, admin)
local PlayerName = args.Player
local target = findPlayer(PlayerName)
if not target or not target.Character then return "Player not found." end
local hrp = target.Character:FindFirstChild("HumanoidRootPart")
if hrp then
local fly = hrp:FindFirstChild("FlyVelocity")
if fly then fly:Destroy() end
logCommand("Unfly", admin, target.Name)
return "✅ " .. target.Name .. " stopped flying"
end
return "No fly state found."
end
module["Kill"] = function(args, admin)
local PlayerName = args.Player
local target = findPlayer(PlayerName)
if target and target.Character then
target.Character:BreakJoints()
logCommand("Kill", admin, target.Name)
return "✅ Killed " .. target.Name
end
return "Player not found."
end
module["Speed"] = function(args, admin)
local PlayerName, Value = args.Player, tonumber(args.Value)
local target = findPlayer(PlayerName)
if target and target.Character and Value then
target.Character.Humanoid.WalkSpeed = Value
logCommand("Speed", admin, target.Name, "Set to " .. Value)
return "✅ Speed set to " .. Value .. " for " .. target.Name
end
return "Invalid input."
end
module["Jump"] = function(args, admin)
local PlayerName, Value = args.Player, tonumber(args.Value)
local target = findPlayer(PlayerName)
if target and target.Character and Value then
target.Character.Humanoid.JumpPower = Value
logCommand("Jump", admin, target.Name, "Set to " .. Value)
return "✅ JumpPower set to " .. Value .. " for " .. target.Name
end
return "Invalid input."
end
return module
2. NPC Spawn System with Balanced Chances (ServerScriptService > Script)
lua
--// NPC Spawn System with Balanced Percentages
local NPCFolder = workspace:FindFirstChild("NPCs") or Instance.new("Folder")
NPCFolder.Name = "NPCs"
NPCFolder.Parent = workspace
-- NPC Configuration (percentages must add up to 100)
local NPCTypes = {
{Name = "Common NPC", Model = "rbxassetid://123456", Chance = 60}, -- 60%
{Name = "Rare NPC", Model = "rbxassetid://234567", Chance = 30}, -- 30%
{Name = "Epic NPC", Model = "rbxassetid://345678", Chance = 9}, -- 9%
{Name = "Legendary NPC", Model = "rbxassetid://456789", Chance = 1} -- 1%
}
-- Validate percentages
local totalChance = 0
for _, npc in ipairs(NPCTypes) do
totalChance = totalChance + npc.Chance
end
assert(totalChance == 100, "NPC chances must add up to 100%")
-- Function to select NPC based on percentage
local function selectNPC()
local roll = math.random() * 100
local cumulative = 0
for _, npcType in ipairs(NPCTypes) do
cumulative = cumulative + npcType.Chance
if roll <= cumulative then
return npcType
end
end
return NPCTypes[1] -- Fallback
end
-- Spawn NPC function
local function spawnNPC(position)
local npcType = selectNPC()
-- Create NPC (replace with your actual NPC models)
local npc = Instance.new("Model")
npc.Name = npcType.Name
-- Example NPC creation (customize this)
local humanoid = Instance.new("Humanoid")
humanoid.Parent = npc
local rootPart = Instance.new("Part")
rootPart.Name = "HumanoidRootPart"
rootPart.Size = Vector3.new(2, 2, 1)
rootPart.Position = position
rootPart.Anchored = false
rootPart.CanCollide = false -- Make walk-through
rootPart.Parent = npc
-- Add body parts (customize appearance)
local head = Instance.new("Part")
head.Name = "Head"
head.Size = Vector3.new(2, 1, 1)
head.Position = position + Vector3.new(0, 1.5, 0)
head.CanCollide = false
head.Parent = npc
-- Weld parts together
local weld = Instance.new("WeldConstraint")
weld.Part0 = rootPart
weld.Part1 = head
weld.Parent = rootPart
npc.PrimaryPart = rootPart
npc.Parent = NPCFolder
-- Make NPC walk-through for all parts
makeNPCWalkThrough(npc)
print("Spawned: " .. npcType.Name .. " (" .. npcType.Chance .. "% chance)")
return npc
end
-- Function to make NPCs walk-through
function makeNPCWalkThrough(npc)
for _, part in ipairs(npc:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
part.CanTouch = false
part.CanQuery = false
-- Create selection box for visibility
local selectionBox = Instance.new("SelectionBox")
selectionBox.Adornee = part
selectionBox.Color3 = Color3.new(0, 1, 0)
selectionBox.Transparency = 0.8
selectionBox.Parent = part
end
end
-- Prevent physics manipulation
local humanoid = npc:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.PlatformStand = false
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
end
end
-- Example spawn loop
while true do
wait(5) -- Spawn every 5 seconds
local spawnPosition = Vector3.new(
math.random(-50, 50),
5,
math.random(-50, 50)
)
spawnNPC(spawnPosition)
end
3. Walk-Through NPCs Script (For existing NPCs)
lua
--// Make All NPCs Walk-Through (ServerScriptService)
local RunService = game:GetService("RunService")
local function makeNPCWalkThrough(character)
-- Wait for character to load
wait(0.1)
-- Make all parts non-collidable
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
part.CanTouch = false
part.CanQuery = false
-- Optional: Add transparency effect
if part.Name ~= "HumanoidRootPart" then
part.Transparency = part.Transparency + 0.1
end
end
end
-- Protect humanoid from physics glitches
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
-- Disable states that can cause glitches
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Flying, false)
-- Set properties to prevent manipulation
humanoid.PlatformStand = false
humanoid.Sit = false
humanoid.MaxHealth = math.huge
humanoid.Health = math.huge
-- Anchor the root part periodically to prevent physics glitches
local rootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso")
if rootPart then
-- Create BodyPosition to keep NPC in place
local bodyPos = Instance.new("BodyPosition")
bodyPos.MaxForce = Vector3.new(4000, 4000, 4000)
bodyPos.Position = rootPart.Position
bodyPos.Parent = rootPart
-- Update position if NPC needs to move
RunService.Heartbeat:Connect(function()
if rootPart.Parent and humanoid.Health > 0 then
-- Keep NPC upright
rootPart.CFrame = CFrame.new(rootPart.Position) * CFrame.Angles(0, rootPart.CFrame:ToEulerAnglesYXZ(), 0)
end
end)
end
end
-- Add anti-exploit tag
local config = Instance.new("Configuration")
config.Name = "NPCConfig"
config.Parent = character
local protected = Instance.new("BoolValue")
protected.Name = "Protected"
protected.Value = true
protected.Parent = config
end
-- Apply to all existing NPCs
for _, npc in ipairs(workspace:GetDescendants()) do
if npc:FindFirstChildOfClass("Humanoid") and not game.Players:GetPlayerFromCharacter(npc) then
makeNPCWalkThrough(npc)
end
end
-- Apply to new NPCs
workspace.DescendantAdded:Connect(function(descendant)
if descendant:IsA("Model") and descendant:FindFirstChildOfClass("Humanoid") then
wait(0.1)
if not game.Players:GetPlayerFromCharacter(descendant) then
makeNPCWalkThrough(descendant)
end
end
end)
print("✅ NPC Protection System Active")