attempt to index a nil value

local function loadScene ( nextScene ) local nextScreen = require(nextScene).new() nextView:insert(nextScreen) return nextScreen end

why im having error attempt to index a nil value?

Do you have a lua file called nextScene?
That what you are saying when you call require

Lua is case sensitive. Remember that.

The way you’re using nextScene is as a variable. What is the contents of nextScene? Perhaps you should print out the value of nextScene?

Rob

It looks like you’re using the director class for your scene handling from the error message?

I really don’t know, but I was under the impression that Director Class was never updated for graphics 2.0. I don’t think I’ve seen a new version for several years. If so, I think you may find it a bit painful to work with compared to the Composer library.

https://docs.coronalabs.com/guide/system/composer/index.html

Director has never been updated as far as I can tell.

Do you have a lua file called nextScene?
That what you are saying when you call require

Lua is case sensitive. Remember that.

The way you’re using nextScene is as a variable. What is the contents of nextScene? Perhaps you should print out the value of nextScene?

Rob

It looks like you’re using the director class for your scene handling from the error message?

I really don’t know, but I was under the impression that Director Class was never updated for graphics 2.0. I don’t think I’ve seen a new version for several years. If so, I think you may find it a bit painful to work with compared to the Composer library.

https://docs.coronalabs.com/guide/system/composer/index.html

Director has never been updated as far as I can tell.