From 7990f94a06bdf5cc79561a49d17d113e36392b55 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Tue, 2 Jul 2024 18:52:18 +0200 Subject: [PATCH] Add a few guards --- lib/init.luau | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/init.luau b/lib/init.luau index 1acc493..83a61b0 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -452,10 +452,14 @@ end function World.clear(world: World, entityId: i53) --TODO: use sparse_get (stashed) local record = world.entityIndex.sparse[entityId] - - local ROOT_ARCHETYPE = world.ROOT_ARCHETYPE + if not record then + return + end - if record.archetype == nil or record.archetype == ROOT_ARCHETYPE then + local ROOT_ARCHETYPE = world.ROOT_ARCHETYPE + local archetype = record.archetype + + if archetype == nil or archetype == ROOT_ARCHETYPE then return end