How do I check if a prop has been disposed of after an IsValid check?

Hello all, I’m pretty lost at the route to take here, The code I’m running is this:

for(idx -> Item : ItemsToShow):
    if(D := ItemsToShowMap[idx]):
        if(CurrentValueInt := Int[D.Prop.GetTransform().Translation.Z],InitialValueInt := Int[D.InitialZLocation]):
        if(CurrentValueInt = InitialValueInt):
                        
            PropPos := D.Prop.GetTransform().Translation

            if(D.Prop.IsValid[]):
                Print("The prop is valid teleporting {idx}.") 
          if(D.Prop.TeleportTo[vector3{X:=PropPos.X,Y:=PropPos.Y,Z:=D.HiddenZLocation},D.Prop.GetTransform().Rotation]){}
   if(CurrentResetAmount <= PropsHiddenAtATime):
       set CurrentResetAmount += 1
   else:
       Sleep(0.01)
       set CurrentResetAmount = 0
else:
       Print("The prop is not valid.")

Tried to format it but that last line wont move right!

Anyway. I tried adding the IsValid check but I’m still getting this error:
LogVerse: Warning: Game_teleport_to_debug_log: (Rolling Back) TeleportTo error: The specified object has been disposed or is otherwise invalid.

So the prop is valid but has been disposed of…
That then fails and drops out of the bottom of my loop and so it never makes it to the end of the 9 I’m expecting to hit, example log:

LogVerse: : ItemsToShow Length Count: 10
LogVerse: : Processing Index: 0 Prop: {x=1965.799484,y=-15964.527849,z=1070.000000}
LogVerse: : The prop is valid teleporting 0.
LogVerse: : Processing Index: 1 Prop: {x=1328.672937,y=-14341.205204,z=1070.000000}
LogVerse: : The prop is valid teleporting 1.
LogVerse: : Processing Index: 2 Prop: {x=-322.202978,y=-16308.442062,z=1070.000000}
LogVerse: : The prop is valid teleporting 2.
LogVerse: : Processing Index: 3 Prop: {x=2668.808300,y=-15755.627560,z=1320.887396}
LogVerse: : The prop is valid teleporting 3.
LogVerse: : Processing Index: 4 Prop: {x=2701.401747,y=-15753.611276,z=1288.665947}
LogVerse: : The prop is valid teleporting 4.
LogVerse: : Processing Index: 5 Prop: {x=2770.996652,y=-15751.312163,z=1161.065202}
LogVerse: : The prop is valid teleporting 5.
LogVerse: : Processing Index: 6 Prop: {x=2687.308609,y=-15460.212292,z=1169.590469}
LogVerse: : The prop is valid teleporting 6.
LogVerse: Warning: Game_teleport_to_debug_log: (Rolling Back) TeleportTo error: The specified object has been disposed or is otherwise invalid.
LogVerse: : ItemsToShow Length Count: 9

What can I do about this? It doesn’t seem like there is a try catch feature in verse? or is there something I can do to handle this error gracefully to not fall over?

Move the Teleport Function Inside the if statement for .IsValid so it only teleports if the prop is valid

Sorry this is inside it, just wouldn’t let me format it correctly, never thought I could throw a screenshot in but heres how it should look:


Solved it. Closing.

1 Like