Sending a PM to all admins in game, BAE 2.0

  1. What do you want to achieve?
    Make a command with BAE 2.0 to pm a message to all the admins in game.

  2. What is the issue?
    The issue is that it gives me an error, what i’m thinking it is that it can’t find the player (admins)

  3. What solutions have you tried so far? I have looked through the forums, found nothing.

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

	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 returnPlayers = Data[1][7]
	local cleanData = Data[1][8] 
	local pluginName = 'pmadmins'
	local pluginPrefix = Prefix
	local pluginLevel = 2
	local pluginUsage = "Message" 
	local pluginDescription = "tp players in that group to their room"
	local playerService = game:GetService('Players')
	local function pluginFunction(Args)
		for a,b in next,playerService:GetPlayers() do
			local PlayerPermission = returnPermissions(b)
			local PlayerPermissions = PlayerPermission > 1
			print("a") -- Prints were to check if ^ got through

	local descToReturn
	if pluginUsage ~= "" then
		descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
		descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription

	return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}

return Plugin

Looks like you’ve got the order of the arguments when firing the RemoteEvent wrong - though there is no documentation for Basic Admin Essentials you can look at its module code for some pointers on how to use various functions. When importing the module in Studio, it’ll appear under the “My Packages” section of your Toolbox, not “My Models”.

It should be noted that the code below will send a PM to admins but this PM will NOT be able to be replied to. In order to make people be able to reply to it, you’ll have to edit the Basic Admin Essentials source code as it stores the IDs for private messages in a table for reference. You can take a look inside the “PM” function somewhere around line 900 for more details on that.

Make sure to filter the combinedMessage before firing it in the remote as it will not automatically be filtered when it reaches the user. You can use the built-in cleanData function of Basic Admin Essentials for this.

local function pluginFunction(Args)
    local sender = Args[1]
    local combinedMessage = table.concat(Args, " ", 3) -- make sure to filter this somewhere in your code

    for _,player in playerService:GetPlayers() do
        local playerPermission = returnPermissions(player)
        local isAdmin = playerPermission > 1
        if isAdmin then
            remoteEvent:FireClient(player, "PM", sender.Name, combinedMessage)
            -- See note above for explanation
1 Like

Thank you so much for your help and replying so quick! Have a great summer and I hope to see you again when I need help. and I do have the module, I was about to look through it until I saw your message

1 Like