Is there a way to get args[6] and so on without having to put them all down which would take forever or just keep it with a limited amount of argumentd.
Its apart of a admin system I have and when the player speaks like :kill TaxFraudBruh, “TaxFraudBruh” is one of the arguments in the command. In this case, I’m wanting all of the arguments after :disguise but I don’t know how to do it without having to add them all to the table.
I’m still kind of confused. If you chat “:kill TaxFraudBruh”, the server gets the message as a string. And normally you do something like string.split(message," ") to split the string into the pieces between the spaces. You get a table.
But I don’t know where your ‘args’ table is coming from, the chat system doesn’t send anything in a table like this, and Roblox Lua doesn’t use args in functions with varargs parameters, you have to convert to array with {…} or use select()
This is where args comes from, I’m not sure how much code I have to show but this is where it gets it from.
plr.Chatted:Connect(function(msg, recp)
string.lower(msg)
local msgString = msg:split(" ") -- table, {":kill","Builderman"}
local prefixCommand = msgString[1] -- ":kill"
local cmd = prefixCommand:split(data.prefix) -- {":","kill"}
local cmdName = cmd[2] -- "kill"
if commands[cmdName] then
local args = {}
for i = 2, #msgString, 1 do
table.insert(args, msgString[i])
end
commands[cmdName](plr, args) -- Fire command function
end
end)
Why do you split the message into a table and then reconstruct the string, why not just pass the message string if that’s what you need. What am I missing here? You can rebuild the string in a loop, without having to list out args[1], args[2] etc… but why do any of this in the first place?