Attempt to call a nil value when xpcall doesn't return an error

When runGame() completes without any errors, the error function will still run and say attempt to call a nil value. I tested this by just calling runGame() with no xpcall and I didn’t get any errors.

local function warnWithTracebackOnError()
	xpcall(runGame(), function(err)
		warn(tostring(err) .. "\n" .. debug.traceback())
        --other code
	end)
end
warnWithTracebackOnError()

You are calling the function within the argument. You just need to pass the identifier.

xpcall(runGame, ...)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.