Programm doesnt work after Reset

Hello, I’ve been sitting on this problem for days and can’t find a solution.
I dont understand the Errormessages, please help… Thanks a 1000x times

I am creating parts with a component creator in a component container and unloading them from it with a robot.

Creator:
creator250 = comp.getBehaviour(“ComponentCreator250”)
creator250_output = creator250.getConnector(0)
ComponentContainer_1 = comp.getBehaviour(“ComponentContainer_1”)
ComponentContainer_1_input = ComponentContainer_1.getConnector(0)
creator250_output.connect(ComponentContainer_1_input)
part1 = creator250.create()
delay(0)

Robot:
global part
part = P1.HeadComponent
delay(0.1)
robot.jointMoveToComponent(Part,Tx=0,Ty=0,Tz=100,Ry=0)
robot.linearMoveToComponent(Part,Tx=0,Ty=0,Tz=0,Ry=0)
robot.graspComponent(Part)

When I open the simulation and press start everything works.
As soon as I reset and restart I get the following error messages:

in jointMoveToComponent
statement = doRSL(self, VC_STATEMENT_PTPMOTION, robotMove)
in doRSL
readFromTarget(robo, robotMove, statement)
in readFromTarget
position = statement.Positions[0]
ReferenceError: Object no longer exists.

How can I fix this?

Translated with DeepL Translate: The world's most accurate translator (free version)

My guess is that something deletes the statement object on reset or otherwise, so you will need to get it again before trying to use it.

It might get replaced with an identical object, but your variable would still point to the old deleted one.