Jump to content

Recommended Posts

Posted

I am trying to spawn a group, and then destroy it, so that I am able to spawn it again.

I trigger both the Spawn, and then Destroy, from menu items for now, as I learn.

My Spawn script file:

LostCar = SPAWN:New( "Lost Car" )
    :OnSpawnGroup( 
        function( SpawnGroup )
            SpawnedLostCar = SpawnGroup.GroupName
        end
    )
    :Spawn()
    
LostPerson = SPAWN:New( "Lost Person" )
    :OnSpawnGroup( 
        function( SpawnGroup )
            SpawnedLostPerson = SpawnGroup.GroupName
        end
    )
    :Spawn()

This works. My groups spawns in, and all is great!

But when I try destroy, things go bad.

Here's my destroy script:

DestroyCar = GROUP:FindByName(SpawnedLostCar)
DestroyPerson = GROUP:FindByName(SpawnedLostPerson)

DestroyCar:Destroy()
DestroyPerson:Destroy()

Nothing happens. But my log file reveals the error:

Quote

ERROR   SCRIPTING (Main): Mission script error: [string "SpawnedLostCar = GROUP:FindByName(SpawnedLostCar)..."]:5: attempt to index global 'SpawnedLostCar' (a nil value)
stack traceback:
    [C]: ?
    [string "SpawnedLostCar = GROUP:FindByName(SpawnedLostCar)..."]:5: in main chunk

It seems it can't find the SpawnedLostCar group. How can I fix this?

🧠 AMD Ryzen 7 7700X | 🧬 32GB DDR5 | 🎮 RTX 3080 | 🥽 Meta Quest 3

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...