This is a great teaching moment. The error:
attempt to index upvalue ‘score’ (a number value)
“Attempting to index” means it’s trying to look something up in a table. Modules return tables. Tables have members (functions, variables) that are indexed in the parent table. This tells me you’re trying to look up a method named “get” in a table named “score”, but Lua found that score is a number, not table.
This is likely due to something like:
local score = require("score")
then later on doing:
score = 0
You basically can’t use the same variable for two different purposes. “score” is a logical name to hold the value of the score. It’s perhaps not the best name for the module. Maybe you should consider:
local scoreManager = require(“score”) – though I would rename score.lua to scores.lua or scoremanager.lua…
Then call scoreManager.get() just so it’s obviously different that “score”.
Rob