Although at this point it’s getting kinda complicated, you might want to just have a function for finding a command from it’s alias by searching through commands, like Kaiden suggested
Yes, I’m aware, but another issue will come if I do that.
I would need the aliases to be able to get to the Execute function somehow.
EDIT: Oh, but I don’t think concat even works on dictionaries in the first place?
This was just a test, it serves no functionality at the moment. Just a test command.
CommandsManager.Commands[FixedCommand].Execute won’t support aliases when indexing it like that, so no, it won’t work because it relies the command to be the command’s name, not any alias of it.
I would need to create another command just to add aliases if I want it to work like that, sadly.
Or, if it were possible to assign multiple strings to it, that would work too.
Oh sorry, forgot to change that part. Simply change CommandsManager.Commands[FixedCommand] to Value.
Player.Chatted:Connect(function(Message)
local Args = Message:split(' ')
local Command = Args[1]
local FixedCommand = Command:gsub(CommandsManager.Settings.Prefix, ''):lower()
for Index, Value in pairs(CommandsManager.Commands) do
local Execute
if FixedCommand == Index or table.find(Value.Aliases, FixedCommand) then
Execute = Value.Execute
Execute(Player, Args)
break
end
end
end)
Well, no. Execute is outside of the aliases. That wouldn’t work.
If that were to work, I’d have to copy-paste the execute inside the aliases part, which might create another problem if I don’t include the actual command name in there as well.
Honestly, just try the script, and don’t say it’s wrong UNTIL you try it. You keep saying it won’t work, what am I supposed to say if you won’t even listen to what I have to say? I’m not gonna go into this and keep responding. It’s quite literally almost 4 am for me and I’m trying to help but you won’t even take into account what I am saying.
for i, cmd in pairs(commandsManager) do
if table.find(cmd.Aliases, fixedCommand) then
– run the command
break
end
end
Both yes and no, but not what I prefer.
{“c”, “cmds”}
The issue with this is that it’s a value, and the index would be something like: [1] = ‘c’, [2] = ‘cmds’
The only way to bypass it is by giving it a name so it can be referenced.
There is completely no issue with what he recommended. This is completely why I recommended using table.find() and honestly saves the hassle of referencing it. In fact that’s what I used in the first solution that you didn’t accept for absolutely no reason.
table[index] as you did and table.find(table, commandName) as I was suggesting would do the same thing
local Array = {
["c"] = "c"
}
Array["c"] -- = c so true
local Array2 = {"c"}
table.find(Array2, "c") -- = true
Both will return true in an if statement but the second one is more optimized because making a dictionary just to index a string when you can achieve the same by putting the string in a simple array is useless