Transferring Functions

Hello! I am trying to tackle a system where the script checks if a bool value is true and then if the function in the table shares the same name with it it puts it into another table, I have tried so many different ways and I just can’t seem to get it to work.

local attackFunctions = {
	slash
}
local useableAttacks = {}

for i,values in pairs(config.attacks:GetChildren()) do
	if values.value == true then
		table.insert(useableAttacks, attackFunctions[values.Name])
	end
end

Here is a glimpse of what I am trying to do, albeit this version doesn’t work it is the most recent code I have for it. Any help that will point me in the right direction will be greatly appreciated. Thank you all who help in advance!

You’ll need to have the attackFunctions table be like this, for your current arrangement to work:

local attackFunctions = {
    ["slash"] = slash
}

You may also be able to do it like:

local attackFunctions = {
    slash = slash
}
1 Like

That works! Which funny enough is I had it like that at one point but I really appreciate you bringing that back to my attention. I guess the late-night brainfart got to me lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.