The reason why I am trying to call commandName as a method is to pass the “self” argument to the “tp” function, so the tp function can then use self.teleport(args). The root problem is that I can’t do this:
The reason why I am trying to call commandName as a method is to pass the “self” argument to the “tp” function, so the tp function can then use self.teleport(args). The root problem is that I can’t do this:
local cmds = {}
local function AddCommand(name, func, alias)
cmds[name] = func
for i,v in pairs(alias) do
cmds[v] = func
end
end
AddCommand("teleport", function(args)
if args[2] then
args[1].Character:SetPrimaryPartCFrame(args[2].Character.PrimaryPart.CFrame)
end
end, {"tp"})
--chatted or whatever:
local cmd = cmds[name]
if cmd then
cmd(args)
end