I have this admin command script and everytime a player chats, it says “You do not have permission to chat.” That is the remote event (dont worry that is working). I cant seem to figure out why, but no matter what they say, for example, “hello” its not even a command, but it still fires that remote event.
local Admins = {
"bootsareme";
}
local Prefix = "!"
local Players = game:GetService("Players")
local Commands = {}
Commands.console = function(Sender)
game.ReplicatedStorage.OpenAdminConsole:FireClient(Sender)
end
Commands.warn = function(Sender, Arguments)
local success, fail = pcall(function()
local username = Arguments[1]
table.remove(Arguments, 1)
local message = table.concat(Arguments, " ")
game.ReplicatedStorage.SendSysNotification:FireClient(Players[username], message)
end)
if fail then
game.ReplicatedStorage.PostSystemMsg:FireClient(Sender, "An error occurred: the player specified was not found.")
end
end
Commands.kick = function(Sender, Arguments)
local success, fail = pcall(function()
local username = Arguments[1]
table.remove(Arguments, 1)
local message = table.concat(Arguments, " ")
Players[username]:Kick(message)
end)
if fail then
game.ReplicatedStorage.PostSystemMsg:FireClient(Sender, "An error occurred: the player specified was not found.")
end
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)
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)
if Player:GetRankInGroup(5474151) >= 253 then
table.insert(Admins, Player.Name)
end
Player.Chatted:Connect(function(Message, Recipient)
if not Recipient and IsAdmin(Player) then
ParseMessage(Player,Message)
else
game.ReplicatedStorage.PostSystemMsg:FireClient(Player, "You do not have permission to use this command.")
end
end)
end)