How to update a Module Variable? explanation below
--module script module={} pose = "idle" module.one = function() print(pose) if pose == "walk" then --do stuff and module.two() end end module.two= function() if pose == "walk" then --do stuff and module.one() end end return module
--Local script --require stuff so S = module script S.pose = "walk" --So I change the variable first, then call the function S.one() --but the function says pose == idle when I just changed it .-.
Careful.
Your ModuleScript doesn't ask for module.pose
. It just has pose
as a global variable.
If you want to be able to modify it from the outside, you should use instead refer to module.pose
within the ModuleScript (which the other scripts can touch as in S.pose
)
Nonetheless, I think it would be better to pass the pose as a parameter to a function, rather than modifying the variable directly.