my admin commands are no working
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local Admins = { "Cookie12bo", "Mrpenguin892"}
local function IsAdmin(Player)
for , AdminName in ipairs(Admins) do
if string.lower(Player.Name) == string.lower(AdminName) then
return true
end
end
return false
end
local function AddAdmin(PlayerName)
if not table.find(Admins, PlayerName) then
table.insert(Admins, PlayerName)
Announce(PlayerName .. " has been added as an admin!")
else
Announce(PlayerName .. " is already an admin!")
end
end
local function RemoveAdmin(PlayerName)
for i, AdminName in ipairs(Admins) do
if string.lower(AdminName) == string.lower(PlayerName) then
table.remove(Admins, i)
Announce(PlayerName .. " has been removed from admin!")
return
end
end
Announce(PlayerName .. " is not an admin!")
end
local function Announce(Message)
for , Player in ipairs(Players:GetPlayers()) do
Player:SendMessage("ANNOUNCEMENT: " .. Message)
end
StarterGui:SetCore("SendNotification", {
Title = "ANNOUNCEMENT";
Text = Message;
Duration = 5;
})
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Msg)
local Args = string.split(Msg, " ")
local Command = string.lower(Args[1])
if IsAdmin(Player) then
if Command == ":addadmin" and Args[2] then
AddAdmin(Args[2])
elseif Command == ":removeadmin" and Args[2] then
RemoveAdmin(Args[2])
elseif Command == ":announce" and Args[2] then
local Message = table.concat(Args, " ", 2)
Announce(Message)
end
end
end)
end)
7 Replies
⌛ This post has been reserved for your question.
Hey @KK playz TG! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Please format your code to make it more readable. For java, it should look like this:
this is Lua, not Java
what is the difrence
well, they are two different coding languages. this server is for helping people with Java. you'd get more luck in a Lua discord server or since this appears to be for Roblox, a Roblox server.
thx
Post Closed
This post has been closed by <@1007989688830808074>.