Hello everyone watching this topic, I came across a problem when I was trying to assign a value in a function, in example I call a variable from a script, and run a function in another scripts that changes the variable that I called.
The issue here is, when I run the code, trying to print the variable value given, and it returns the same value I put to call the variable.
I tried multiple solutions such as using return (GivenValue)
but still not working, I didn’t look at the devforum yet, but I will look at it after this post and warn it here if I found a solution for it.
Anyways, here’s some examples about the code I made: (This is an example btw)
Module script that has the function:
local module = {
["AssignTable"] = function(Val1, Val2, Val3, tablegiven)
tablegiven = {"First Value is: " .. Val1, "Second Value is: " .. Val2, "Third Value is: " .. Val3,}
return tablegiven
end)
}
return module
Whatever script:
local tableVal = {}
local modulescript = require(ModulePath) -- Where the module is located
modulescript.AssignTable(1, 2, 3, tableVal)
print(tableVal) -- Should print the given table in the function in my point of view, but only prints "{}", the initial value of the variable
If someone here knows the issue, you can reply to this post, if I did something wrong or if functions shouldn’t be used to make what I did. Thanks!