local function CreateRigFunction()
if RigObject then -- A rig had already been created
print(RigObject)
RigObject:DestroyRig()
end
RigObject = RigControllerModule.new()
end
print(RigObject) does print out the already created object. However, I still get this error, and the method DestroyRig() isn’t executed.
Right, but can you share the exact error message displayed in console? That would be useful since it typically gives information such as the line in the script at which the error occurred etc.
Attempt to call a nil value would otherwise indicate that you’re attempting to call a nil type value as a function. Meaning that the function “DestroyRig” either doesn’t exist or cannot be reached within the body of the function named “CreateRigFunction”.
The error would suggest that the function likely doesn’t exist, that or it wasn’t correctly referenced from the module script. Or the function cannot be accessed from within the scope of the local function named “CreateRigFunction”.
It’s not being recognized in the main script, as the error suggests when attempting to call “DestroyRig”, Lua thinks you’re trying to call a nil value as a function.