Custom Message BAE Plugin

I want to make a BAE plugin that I can send a custom message using the Message system so the command a user would run would be “message [user] [TITLE] [BODY]” what I have is but it is not working.

local Plugin = function(…)
local Data = {…}

– Included Functions and Info
local remoteEvent = Data[1][1]
local remoteFunction = Data[1][2]
local returnPermissions = Data[1][3]
local Commands = Data[1][4]
local Prefix = Data[1][5]
local actionPrefix = Data[1][6]
local returnPlayers = Data[1][7]
local cleanData = Data[1][8]

– Plugin Configuration
local pluginName = ‘message’
local pluginPrefix = Prefix
local pluginLevel = 3 – Admin level required
local pluginUsage = “[USERS/TEAM] [TITLE] [BODY]” – Allow users/team, title, and body to be inserted
local pluginDescription = “Sends a custom message with a chosen title and body to chosen users or teams.”

– Example Plugin Function
local function pluginFunction(Args)
local ArgsTable = {}
for i = 2, #Args do
table.insert(ArgsTable, Args[i])
end
local Targets = ArgsTable[1]
local Title = ArgsTable[2]
local Body = table.concat(ArgsTable, " ", 3)

– Check if targets is USERS or TEAM
if Targets:upper() == “USERS” then
– Get the list of users
local Users = {}
for i = 3, #ArgsTable do
table.insert(Users, ArgsTable[i])
end

– Send the custom message to the specified users
for _, User in pairs(Users) do
local Player = returnPlayers(User)
if Player then
remoteEvent:FireClient(Player, ‘Message’, Title, Body)
else
remoteEvent:FireAllClients(nil, ‘Message’, ‘Error’, ‘Player not found!’)
end
end
elseif Targets:upper() == “TEAM” then
– Get the team name
local TeamName = ArgsTable[3]

– Send the custom message to the specified team
local Team = game.Teams[TeamName]
if Team then
for _, Player in pairs(Team:GetPlayers()) do
remoteEvent:FireClient(Player, ‘Message’, Title, Body)
end
else
remoteEvent:FireAllClients(nil, ‘Message’, ‘Error’, ‘Team not found!’)
end
else
remoteEvent:FireAllClients(nil, ‘Message’, ‘Error’, ‘Invalid targets! Use “USERS” or “TEAM”.’)
end
end

– Return Everything to the MainModule
return pluginName, pluginFunction, pluginLevel, pluginPrefix, {pluginName, pluginUsage, pluginDescription}

end

return Plugin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.