How do I specify layers with persistant objects?

I'm trying to make a persistent object, but whenever I go to the next room, the object is created under another object. I can't seem to specify the depth, and I can't specify the layer in the room it's going to since it's not in the room when I edit it. I'm sorry I sound dumb, I've only been using game maker for a few months and I'm trying to learn from experiencing things, and I would only come to the forums when I have no other option.


From the documentation:

In other words, inside the "Room Start" event, you have the ability to change layer/depth of your object programatically.
Hopefully that is what you were looking for!
I'm really sorry, I should've specified earlier. I'm working with DnD, so I don't think I can just add a string which specifies the depth. If I can, please let me know! But is there a way to specify the depth in DnD?
in the old gamemaker there is a dnd event called set variable, Not sure if or where to find it in game maker studios2 if you choose to set depth it should work.


Yup that worked! Thanks!
Can you please let me know if your object appears in the correct layer? Or is it random?

If I'm not wrong, your object cannot change it's depth based on objects of other layers.
Each layer has it's own "depth management".

Glad it worked with just setting a variable tho!