Okay so, first of all you need a command handler, I’ll make a simple one for you but this is definitely not the most effective one you can do
function sendWebhook(url, content)
print(content)
-- please keep in mind you have to do this part yourself, there are websites you can use which help
end
local url = "" -- webhook url
local Prefix = "!" -- any prefix you want
local Admins = {"Player1", "Player2", "Player3"} -- player name of admin table
local Players = game:GetService('Players')
for i,v in pairs(Players:GetPlayers()) do
if table.find(Admins, v.Name) then -- check if player is in the admin table
v.Chatted:Connect(function(msg) -- chatted function
local checkCommand = string.match(msg, "^"..Prefix) -- check for prefix
if checkCommand then
msg = string.gsub(msg, checkCommand, "", 1) -- change it to just command
local arguments = {}
for argument in string.gmatch(msg, "[^%s]+") do -- add to arguments if there is a space (referenced from another devforum wiki)
table.insert(arguments, argument)
end
local command = arguments[1]
if command == "iso" then -- check for command
local isolatedBy = v.Name -- admin name
local isolatedStudent = arguments[2] -- isolated person name
local isolatedReason = arguments[3] -- isolated reason text
sendWebhook(url, "Isolated Student: "..isolatedStudent.." Isolated By: "..isolatedBy.." Reason: "..isolatedReason) -- what you would do (not exact just reference)
end
else
-- do nothing
end
end)
end
end
To make it easier for you on the string manipulation area
"^"..Prefix
simply checks for the prefix at the start of the message which is why there is ^ (it is the head of the string
)
"[^%s]+"
(the %s simply means a space, and the [] is used for sets, which means multiple checks, so a set of the head of the string,(so a text) then the space and when set is closed, the + which checks if one or more of the character class appears, since it’s inside a set, it will apply to both, the head of the string and the space, without it it’ll just be the space.
By adding these into an argument table, we can easily check for the commands, and be more flexible with the command handler.
Oh and for the table checking, I simply used table.find
, you can use an if check inside a function if you want, but this is just less work so.
I hope you’re able to make what you need, and that this helped. Good luck!