Basic authorive server test

I have been stuck and I have used even AI to try and figure out what is wrong. so I will paste alot of data and hopefully someone can explain or tell me what is wrong while trying to “register authoritive matches”
first here is my basic match lua:

– Basic authoritative match handler for Nakama
local nk = require(“nakama”)

local M = {
match_init = function(ctx, params)
return { state = {} }
end,
match_join = function(ctx, dispatcher, tick, state, presence)
return { state = state }
end,
match_loop = function(ctx, dispatcher, tick, state)
return { state = state }
end,
match_terminate = function(ctx, dispatcher, tick, state)
return { state = state }
end
}
for k, v in pairs(nk) do
nk.logger_info(“nk.” .. k .. ": " .. type(v))
end
nk.logger_info("Type of nk.register_match: " .. type(nk.register_match)) – Should print “function”
nk.logger_info("Type of M: " .. type(M)) – Should print “table”
nk.register_match(“basic_match”, M)

then i get this output and the match_register always returns nil:
I have pruned alot.

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.395Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.register_matchmaker_matched: function”,“runtime”:“lua”}

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.395Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.register_req_after: function”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.395Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.match_create: function”,“runtime”:“lua”}

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.match_signal: function”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.storage_write: function”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.register_leaderboard_reset: function”,“runtime”:“lua”}

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.match_list: function”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:"2025-06-
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.cron_prev: function”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.cron_next: function”,“runtime”:“lua”}

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“nk.match_get: function”,“runtime”:“lua”}

nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“Type of nk.register_match: nil”,“runtime”:“lua”}
nakama-1 | {“level”:“info”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua_nakama.go:2347”,“msg”:“Type of M: table”,“runtime”:“lua”}
nakama-1 | {“level”:“error”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime_lua.go:2288”,“msg”:“Could not complete runtime invocation”,“error”:“/nakama/data/modules/match.lua:23: attempt to call a non-function object\nstack traceback:\n\t/nakama/data/modules/match.lua:23: in main chunk\n\t[G]: ?”}
nakama-1 | {“level”:“error”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“server/runtime.go:676”,“msg”:“Error initialising Lua runtime provider”,“error”:“/nakama/data/modules/match.lua:23: attempt to call a non-function object\nstack traceback:\n\t/nakama/data/modules/match.lua:23: in main chunk\n\t[G]: ?”}
nakama-1 | {“level”:“fatal”,“ts”:“2025-06-15T00:23:37.396Z”,“caller”:“main.go:201”,“msg”:“Failed initializing runtime modules”,“error”:“/nakama/data/modules/match.lua:23: attempt to call a non-function object\nstack traceback:\n\t/nakama/data/modules/match.lua:23: in main chunk\n\t[G]: ?”}

I have tried even examples on github it always ends in failure.
Can someone explain or point me in the correct direction of how I am failing. any advice would help because my authoritive lua for my game is quite large and results with the exact same issue. When I try and register authoritive match it exits with attempt to call a non-function.

@JasonE nk.register_match does not exist in the Lua runtime. Try creating the match by just passing the Lua module name, in your case "basic_match" assuming you have a basic_match.lua file that implements and returns a match handler.

As a side note, please try formatting the code and logs correctly using code blocks - they’re very hard to read and follow otherwise. :person_bowing: