I am trying to figure out how to determine the name of a function inside of a table.
for example.
Thanks in advance!
local function f1()
--function one
end
local function f2()
--function two
end
local function f3()
--function three
end
local Funcs = {f1,f2,f3}
for a, b in ipairs(funcs) do
if b.Name == ("f3") then --how would i do this??
end
end
This is off topic so I’ll keep it short.
You could make custom classes with their own events/functions or export them from module scripts.
Quick example would be
local commands = {}
commands.ban = function(player)
player:Kick("Banned")
end
commands.kick = function(player)
player:Kick("Kicked")
end
The custom classes explanation is pretty advanced and there are other topics on it so I’ll just link to the best one.
local function f1() end
local function f2() end
local function f3() end
local functions = {
["f1"] = f1;
["f2"] = f2;
["f3"] = f3;
}
for index, func in pairs(functions) do
if index == "f3" then
--// do something
end
end
local function Disfunction()
end
local function PosionousPremesis()
end
local Powers = {
["Disfunction"] = Disfunction();
["Posionous Premesis"] = PosionousPremesis();
}
uis.InputBegan:Connect(function(key)
if key.KeyCode == Keybind or key.KeyCode == Keybind2 then
print("Pressed")--prints
for index, TempFunction in pairs(Powers) do
print(""..index)--doesnt print
end
end
end)
Remove the () from the functions you’re running them and setting the indexes to what they return which is nil and removes the indexes from the dictionary.