local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
local Player = Args[1]
if Args[3] then
local target = returnPlayers(Player, Args[3]) if not target then return end
local combinedVictims = ''
for a,b in pairs(target) do
if combinedVictims == '' then
combinedVictims = b.Name
else
combinedVictims = combinedVictims..', '..b.Name
end
end
for a,b in pairs(Args) do
remoteEvent:FireClient(Player, 'Hint', 'Set Role', 'Success')
b.Name.Character.Head.Rank.Frame.Group.Text = "TRAINER"
end
end
end
local function pluginFunction(Args) – keep the name of the function as “pluginFunction”
local Player = Args[1]
if Args[3] then
local target = returnPlayers(Player, Args[3]) if not target then return end
local combinedVictims = ‘’
for a,b in pairs(target) do
if combinedVictims == ‘’ then
combinedVictims = b.Name
else
combinedVictims = combinedVictims…', '…b.Name
end
end
for a,b in pairs(Args) do
remoteEvent:FireClient(Player, 'Hint', 'Set Role', 'Success')
b.Character.Head.Rank.Frame.Group.Text = "TRAINER"
end
end
Thanks for the solution, it now partly works.
But:
I’m still getting the same error if I’m running it on someone else (“train Iv_”). But running just “train” on myself works.
Is the command used like this: :trainer (username)?
Assuming it’s :trainer (username), you can go ahead and try this out:
local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
local Player = table.remove(Args, 1)
local Victims = returnPlayers(Player, Args[2] or '')
if not Victims then
return remoteEvent:FireClient(Player, 'Hint', 'Error', 'Please provide a valid username.')
end
for a,b in next,Victims do
remoteEvent:FireClient(Player, 'Hint', 'Set Role', 'Success')
b.Character.Head.Rank.Frame.Group.Text = "TRAINER"
end
end
Alrighty, I can help with this since I have been modifying BAE quite a lot.
To start off, Args is just a table of strings of each word in the message. So, you are actually looping through strings, not the Player’s Charafcter. So, you have to replace:
for a,b in pairs(Args) do —> for a,b in pairs(target) do
You could also delete the variable combinedTargets and the loop of it since it is not necessary for your code to work.
There is one problem with your code though. Since it is looping through the table, remoteEvent:FireClient(Player, 'Hint', 'Set Role', 'Success') will fire amount to how many targets you have. I suggest putting after the loop, or do necessary checks like if: