I have this admin script and it is supposed to open a gui when a player chats a command. In case you didn’t know, the admin command is !adminconsole
.
local Admins = {
"bootsareme";
"shoesareme";
}
local Prefix = "!"
local Players = game:GetService("Players")
local Commands = {}
Commands.adminconsole = function(Sender, Arguments)
game.Players[Sender.Name].PlayerGui.AdminConsole.Enabled = true
end
local function IsAdmin(Player)
for _,Admin in pairs (Admins) do
if type(Admin) == "string" and string.lower(Admin) == string.lower(Player.Name) then
return true
elseif type(Admin) == "number" and Admin == Player.UserId then
return true
end
end
return false
end
local function ParseMessage(Player,Message)
Message = string.lower(Message)
local PrefixMatch = string.match(Message,"^"..Prefix)
if PrefixMatch then
Message = string.gsub(Message,PrefixMatch,"",1)
local Arguments = {}
for Argument in string.gmatch(Message,"[^%s]+") do
table.insert(Arguments,Argument)
end
local CommandName = Arguments[1]
table.remove(Arguments,1)
local CommandFunc = Commands[CommandName]
if CommandFunc ~= nil then
CommandFunc(Player,Arguments)
end
end
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message,Recipient)
if not Recipient and IsAdmin(Player) then
ParseMessage(Player,Message)
end
end)
end)
I chat the command and it opens up the GUI fine. Once I close the gui, and I proceed to type the command again, the chat stops working. Here is my chat:
bootsareme: !adminconsole --admin gui opens up
bootsareme: !adminconsole --chat for the second time, nothing happens, no errors
That basicaclly describes the problem. I don’t know what is wrong because there are no errors.