Your problem is that you’re trying to verify a parameter that is not exactly what you want anymore.
For example, you’ve sent to the function “Test” the following value: “757” which was derived from the variable “hey”, what you might want to do is keep a variable in the global scope to keep a reference of it while doing the iterations (second example) OR assign the parameter to the updated value for every iteration of the for loop (first example), otherwise, “parm” will be received once unless you do one of these options:
First thing, I’ll be using coroutine.wrap() instead of resume and create, you can keep it the way you want, but understand that wrap will work the same.
Examples:
local hey = 757
coroutine.wrap(function()
wait(5)
hey = 1
end)()
local function Test(parameter)
for i = 1, 10 do
wait(1.5)
parameter = hey -- You assign "parameter" to the "hey"'s value: variable we want to keep track of.
print(parameter==1)
end
end
Test(hey)
print(hey == 1)
print(hey)
OR
local hey = 757
coroutine.wrap(function()
wait(5)
hey = 1
end)()
local function Test() -- In this way we don't use any parameters, but since you wanted them, check the code above.
for i = 1, 10 do
wait(1.5)
print(hey)
end
end
Test()
The code wasn’t tested, but the way you want to really update the “parameter” is just to assign it to the variable you want to keep track of every iteration of the for loop so it’s always updated. (which is the first example)
I hope that’s what you wanted and that answers your question if not just reply and I’ll try to help.
OBS.: If you only have the function inside the module which I just read in notes, just create a global variable (in the module) and assign it from the script to the module using “module.hey = 1” while using the first example, then the parameter will update based in this variable which will be at some point updated, the thing is, there are many ways to do it, but that should do it.
EDIT: Fixed code’s indentation.
EDIT 2: Observation.