Private function for GameObject (SOLVED)

when call to my function hurt in script player, call function hurt in enemie player, so when my player is destroyed hurt in enemie is calling too, is normal?

all function need have different name?

You have fallen into the “global by default” trap in Lua. By default all variables are global. This means that a function declared in one script will be accessible from all scripts. If two global functions have the same name one will replace the other.

You can declare a function or variable as local by prefixing it with the local keyword:

local foo = "bar"
local function boo() ... end

Read more about this in our Lua manual.

2 Likes