I have a modulescript that has the functions to control the partcache and from another script I am calling a function like
print(fireball.Name) -- prints "Fireball" correctly
FireballCacheControllerModuleScript:returnFireballToCache(fireball)
then in the modulescript
function FireballCacheControllerModuleScript.returnFireballToCache(fireBallToReturn: BasePart)
print(fireBallToReturn) -- prints "table:0x9c1a1a7aa07ccfba"
print("returning fireball with name: " .. fireBallToReturn.Name) -- this is line 29
....
end
and the next line throws an error Workspace.Alearning.FireballCacheControllerModuleScript:29: attempt to concatenate string with nil]
Why does the object I am sending turn into a table?
How does this make sense?
I have no idea where to look to solve this or what to try.
Please advise!
ModuleScripts return tables if they have been required already somewhere in the Script, and from what I have heard they also return tables if another Script required it
you are using the incorrect calling method. On your modulescript you have function module.func(args) and on the script that calls you have module:func(args). Change one of them and it should work.
Alr, so what I think you have right now as the code is:
local FireballCacheControllerModuleScript = {}
FireballCacheControllerModuleScript.returnFireballToCache = function()
-- Code thing you put here
end
return FireballCacheControllerModuleScript
What you can do instead is:
local returnFireballToCache = function()
-- Code here again
end
return returnFireballToCache
(This was what I was trying to explain, sorry for talking chinese)