Hey everyone, It’s me again Nehoray
I made Admin Commands that can be executed through Chat
Setup
// Username Version
Start by creating Server Script inside ServerScriptService
Copy and paste this code to the script you just created!
local Admins = {"nehoray1200","Username","Username"} -- Put Here Admins
local BanDatabase = game:GetService("DataStoreService"):GetDataStore("Commands_Data")
local currency = nil -- If nil It will detect automatically
local MarketPlaceService = game:GetService("MarketplaceService")
function CheckCurrency()
wait(1)
if currency ~= nil then return end
for _, plr in pairs(game.Players:GetPlayers()) do
if plr:FindFirstChild("leaderstats") then
for i, value in pairs(plr:FindFirstChild("leaderstats"):GetChildren()) do
if i == 1 and value:IsA("IntValue") or value:IsA("NumberValue") then
currency = value.Name
elseif i > 1 then
currency = nil
print("Too Many Currencies! Please Change It")
end
end
end
end
end
function Ban(player,Reason)
local PlayerId = game.Players:GetUserIdFromNameAsync(player.Name)
local success, errormessage = pcall(function()
BanDatabase:SetAsync(PlayerId.."_BanData",true)
end)
if success and PlayerId ~= game.CreatorId then
player:Kick("You're Banned! Reason: ".. Reason)
end
end
function CheckBan(player)
local data
local success, errormessage = pcall(function()
data = BanDatabase:GetAsync(player.UserId.."_BanData")
end)
if success and data ~= nil and data and player.UserId ~= game.CreatorId then
player:Kick("You're Banned!")
end
end
game.Players.PlayerAdded:Connect(function(player)
CheckBan(player)
CheckCurrency()
for i, Admin in pairs(Admins) do
if player.Name == Admin then
player.Chatted:Connect(function(message)
local msg = string.lower(message)
local msgSplit = msg:split(" ")
-- /kick nehoray1200
if msgSplit[1] == "/kick" and msgSplit[2] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local playerFound = game.Players:FindFirstChild(plr)
if playerFound then
playerFound:Kick("You Got Kicked")
end
end
end
elseif msgSplit[1] == "/ban" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local playerFound2 = game.Players:FindFirstChild(plr)
if playerFound2 then
print("Ban")
Ban(playerFound2,msgSplit[3])
end
end
end
elseif msgSplit[1] == "/shutdown" then
for i, plr in pairs(game.Players:GetPlayers()) do
plr:Kick("Server Shutdown")
wait(0.5)
end
elseif msgSplit[1] == "/bring" and msgSplit[2] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local lowerPlayer3 = string.lower(msgSplit[2])
local playerBring = game.Players:FindFirstChild(plr)
if playerBring and playerBring.Character and playerBring.Character:FindFirstChild("HumanoidRootPart") then
print("Bring")
playerBring.Character:FindFirstChild("HumanoidRootPart").CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0,15,0)
end
end
end
elseif msgSplit[1] == "/add" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
local PlayerFound = game.Players:FindFirstChild(msgSplit[3])
local Amount = tonumber(msgSplit[2])
if PlayerFound and Amount then
PlayerFound:FindFirstChild("leaderstats"):FindFirstChild(currency).Value += Amount
end
elseif msgSplit[1] == "/remove" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
local PlayerFound = game.Players:FindFirstChild(msgSplit[3])
local Amount = tonumber(msgSplit[2])
if PlayerFound and Amount then
PlayerFound:FindFirstChild("leaderstats"):FindFirstChild(currency).Value -= Amount
end
end
end)
end
end
end)
Change the Admin Table to your username and your mods username
If you’ve 1 currency in the game It will detect that automatically
// UserId Version
Start by creating Server Script inside ServerScriptService
Copy and paste this code to the script you just created!
local Admins = {1,2,3} -- Put Here Admins ID
local BanDatabase = game:GetService("DataStoreService"):GetDataStore("Commands_Data")
local currency = nil -- If nil It will detect automatically
local MarketPlaceService = game:GetService("MarketplaceService")
function CheckCurrency()
wait(1)
if currency ~= nil then return end
for _, plr in pairs(game.Players:GetPlayers()) do
if plr:FindFirstChild("leaderstats") then
for i, value in pairs(plr:FindFirstChild("leaderstats"):GetChildren()) do
if i == 1 and value:IsA("IntValue") or value:IsA("NumberValue") then
currency = value.Name
elseif i > 1 then
currency = nil
print("Too Many Currencies! Please Change It")
end
end
end
end
end
function Ban(player,Reason)
local PlayerId = game.Players:GetUserIdFromNameAsync(player.Name)
local success, errormessage = pcall(function()
BanDatabase:SetAsync(PlayerId.."_BanData",true)
end)
if success and PlayerId ~= game.CreatorId then
player:Kick("You're Banned! Reason: ".. Reason)
end
end
function CheckBan(player)
local data
local success, errormessage = pcall(function()
data = BanDatabase:GetAsync(player.UserId.."_BanData")
end)
if success and data ~= nil and data and player.UserId ~= game.CreatorId then
player:Kick("You're Banned!")
end
end
game.Players.PlayerAdded:Connect(function(player)
CheckBan(player)
CheckCurrency()
for i, Admin in pairs(Admins) do
if player.UserId == Admin then
player.Chatted:Connect(function(message)
local msg = string.lower(message)
local msgSplit = msg:split(" ")
-- /kick nehoray1200
if msgSplit[1] == "/kick" and msgSplit[2] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local playerFound = game.Players:FindFirstChild(plr)
if playerFound then
playerFound:Kick("You Got Kicked")
end
end
end
elseif msgSplit[1] == "/ban" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local playerFound2 = game.Players:FindFirstChild(plr)
if playerFound2 then
print("Ban")
Ban(playerFound2,msgSplit[3])
end
end
end
elseif msgSplit[1] == "/shutdown" then
for i, plr in pairs(game.Players:GetPlayers()) do
plr:Kick("Server Shutdown")
wait(0.5)
end
elseif msgSplit[1] == "/bring" and msgSplit[2] ~= nil then
for _, plrs in pairs(game.Players:GetPlayers()) do
local plr = string.lower(plrs.Name)
if string.find(plr,string.lower(msgSplit[2])) then
local lowerPlayer3 = string.lower(msgSplit[2])
local playerBring = game.Players:FindFirstChild(plr)
if playerBring and playerBring.Character and playerBring.Character:FindFirstChild("HumanoidRootPart") then
print("Bring")
playerBring.Character:FindFirstChild("HumanoidRootPart").CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0,15,0)
end
end
end
elseif msgSplit[1] == "/add" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
local PlayerFound = game.Players:FindFirstChild(msgSplit[3])
local Amount = tonumber(msgSplit[2])
if PlayerFound and Amount then
PlayerFound:FindFirstChild("leaderstats"):FindFirstChild(currency).Value += Amount
end
elseif msgSplit[1] == "/remove" and msgSplit[2] ~= nil and msgSplit[3] ~= nil then
local PlayerFound = game.Players:FindFirstChild(msgSplit[3])
local Amount = tonumber(msgSplit[2])
if PlayerFound and Amount then
PlayerFound:FindFirstChild("leaderstats"):FindFirstChild(currency).Value -= Amount
end
end
end)
end
end
end)
Change the Admin Table to your UserId and your mods UserId
If you’ve 1 currency in the game It will detect that automatically
Commands
Commands List:
--[[
All Commands
- /bring Username -- Bring the player
- /add 50 Username -- Add 50 Cash value
- /remove 50 Username -- Remove 50 Cash value
- /ban Username Reason -- Ban The player
- /kick Username -- Kick the user
- /shutdown -- Kick all players from the server
That's all more may come!
--]]
I hope you found that useful thanks for reading!
If you’ve any suggestions or Ideas for improvement leave it below!