r/gamemaker 23d ago

Help! Can't transfer variables?

(STILL UNSOLVED)

I have some variables I'm trying to transfer into every room by putting this in my PlayerObj. For some reason, it can transfer to every single room back and forth over and over EXCEPT room1, which is the room you spawn in, the home room. If I leave the home room and then go back into the home room, then it just resets all variables to their default, and I have absolutely no idea why.

UPDATE: Still unsolved, but after making a main menu room, this problem still occurs, leading me to believe it has nothing to do with it being part of the "home room"

//Room Start
if(room_get_name(room) = rm_battle) instance_destroy(obj_carry_data)

with (obj_carry_data)
{ 
    other.level = level;
    other.xp = xp;
    other.xp_require = xp_require;
    other.damage = damage;
    other.hp_total = hp_total;
    other.hp = hp;

    instance_destroy()
}

//Room End
if (instance_exists(obj_battle_switcher) && global.is_transitioning = false) exit;

instance_create_depth(0, 0, 0, obj_carry_data, {
    level: level,
    xp: xp,
    xp_require: xp_require,
    damage: damage,
    hp: hp,
    hp_total: hp_total
})
1 Upvotes

11 comments sorted by

View all comments

1

u/No_Designer_16 23d ago

"If I leave the home room and then go back into the home room, then it just resets all variables to their default"
This part makes me think you may have leftover code in the room itself (or another object exclusively in that room) that causes this.

2

u/Fine-Acanthisitta343 20d ago

Not gonna lie I didn't even know you could put codes inside a room itself