ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
Luacrash

InvokeNative: execution failed: bad any_cast

Also seen as: bad any_cast InvokeNative bad any cast any_cast error linux server

What causes it

A native received an argument of the wrong type — the server tried to cast it and failed. Often surfaces after moving a server to Linux, where stricter type handling exposes a wrong argument type (e.g. passing a string where a number is expected) that Windows tolerated.

How to fix it

Correct the argument type passed to the native.

  1. Find the native and resource in the stack trace.
  2. Check the arguments — a common cause is passing a string instead of a number, or vice versa.
  3. Convert types explicitly (tonumber / tostring) where needed.
  4. If it only started after a Linux move, the code was passing a wrong type that Windows silently accepted.

Related errors

Related guides

Still stuck? We can help.

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.