Hi everyone,
I’m working on a small auto-battler project where I generate cats (TokenCat) using a function that receives:
in_rol(text) → the role name (like"tank")out_obj(object) → the cat instance to fillroles(structure) → a variable containing all role datanextId(number) → id countertxt_debug(object) → a text object for debugging
Everything works except one thing:
Inside the function, I can correctly read the structure (for example rolesRef.tank.color gives "orange"),
but when I write the variables into the object with ModVarObjetTxt or ModVarObjet, all values appear as 0 in the debug output.
Example of the debug text after creation:
id=c1 | rol=0 | color=0 | V:0 A:0 S:0 | hab=0
However, VariableString(rolesRef.tank.color) prints "orange" correctly inside the same function.
Here is the simplified version of what I’m doing inside the function:
CopyArgumentToVariable2("roles", rolesRef)
CopyArgumentToVariable2("nextId", tmpNextId)
tmpRole = VariableString(in_rol)
vmin = Variable(rolesRef[VariableString(tmpRole)].vida[0])
vmax = Variable(rolesRef[VariableString(tmpRole)].vida[1])
tmpColor = VariableString(rolesRef[VariableString(tmpRole)].color)
tmpHab = VariableString(rolesRef[VariableString(tmpRole)].hab)
vida = floor(RandomInRange(Variable(vmin), Variable(vmax)))
out_obj id = "c" + ToString(Variable(tmpNextId))
out_obj rol = tmpRole
out_obj color = tmpColor
out_obj vida = vida
out_obj hab = tmpHab
No errors, but every value except id is shown as 0.
So far I’ve verified:
- The structure (
rolesRef) is correct — I can print any field likerolesRef.tank.color="orange". - The function is called correctly inside a
For each TokenCat. - The parameters are passed in the right order.
Could it be a typing or scope issue when assigning to out_obj from inside a function?
Do object variables keep their old types (number vs string) if they were initialized before?
Any ideas or clarifications about how GDevelop handles object variables in functions would be super appreciated ![]()

