Still have questions? Join our Discord server and get real time help.
0

# Why is the __nodes table nil in a certain method, but it isn't for another method?

Edited 2 months ago

(UPDATE: Everything else, including __nodes, is returning nil)

I am working on a CameraAPI. I am stumped on one thing, though. This used to work before (with the same code), but now it doesn't

I have a CameraApi table. It uses a constructor:

CameraApi:Instantiate()


The module itself calls this constructor on its last line of code

return CameraApi:Instantiate


(NOTE: I use self since CameraApi:Instanstiate() is syntax suguar for CameraApi.Instanstiate(CameraApi); self is an implicit argument which is CameraApi) The constructor returns the following metatable:

return setmetatable(Info, self)


Here's where I go deeper into the problem. In Info, there is a class called Cutscene with the constructor :CreateCutscene with the argument CutsceneName (which is stored in its "Info" table)

Now, I need to explain the functions. It has a __nodestable. It's with two underscores because it is meant to be private.

I use getters(accessors) and setters(mutators) for my Cutscene class

function Info.Cutscene:GetNodes()
return self.__nodes
end


I have a handy function which changes where the Camera Node faces.

function Info.Cutscene:SetNodeDirection()
-- ...
end


Whenever I call :GetCameraNodes or print it, it returns nil

(By the way, there is nothing that sets __nodes to nil or something like that)

(Reminder: __nodes is nil in :SetNodeDirection, but not in :GetNodes or outside the module)

(It worked before; is it a bug from roblox?)

0
this may be a bug in the CoreScript, not sure TerrodactyI 158 — 2mo
0
I don't think that the code (or whatever) that makes up lua (5.1) is in the CoreScripts. It would most likely be in the RobloxStudio files saSlol2436 674 — 2mo
0
i think it would be better if you included a larger part of your script, as somethings you mentioned such as Info. and Info.Cutsene aren't defined anywhere in the code snippets, nor did you point to what either of them was. theking48989987 1726 — 2mo