#Dynamic Module Script Functions

1 messages · Page 1 of 1 (latest)

glass aurora
#

I have a module script that has different functions attributed to it. I'd like to swap between the functions based on what I need it to do, but I don't want to create a separate variable for each function. Is there a way to swap between the module functions?

Current code strip below:
local animationSet = Animations.Set1() -- How can I rewrite this to be dependent on a variable passed into the function?

teal compass
#

🏴‍☠️

haughty mason
glass aurora
# haughty mason I don't quite understand your question. Can you provide an example?

I'm running a local script to play animations for bots within my game, and I have another script passing in which animation to play. The line of code I have above is connected to a module script that holds the bot's animations through a function that contains a dictionary. I'm wondering if it's possible to change which function is used in the module script.

Example:
MODULE SCRIPT
local modulescript = {}

function modulescript.Set1()
--table
end

function modulescript.Set2()
--table
end

return modulescript

LOCAL SCRIPT
modulescript = require(modulescript)
local passedAnims = set1
local animationSet = modulescript.passedAnims <- This is the part that I'm unsure about. can this be altered in any way to

haughty mason
#

We need to redesign your approach

#

There is no reason for you to have a dictionary of animations "stored" within a function