@@ -742,7 +742,7 @@ function Observer.observeGroup(
742742 return self :observe (function (_ , zone , entity : any )
743743 local groups = State .entityToGroups [entity ]
744744 if not groups then
745- return
745+ return nil
746746 end
747747
748748 for groupId , _ in groups do
@@ -808,7 +808,7 @@ function Observer.onGroupEnter(
808808 return self :observe (function (_ , zone , entity : any )
809809 local groups = State .entityToGroups [entity ]
810810 if not groups then
811- return
811+ return nil
812812 end
813813
814814 for groupId , _ in groups do
@@ -865,7 +865,7 @@ function Observer.onGroupExit(
865865 return self :observe (function (_ , zone , entity : any )
866866 local groups = State .entityToGroups [entity ]
867867 if not groups then
868- return
868+ return nil
869869 end
870870
871871 for groupId , _ in groups do
@@ -1385,8 +1385,8 @@ end
13851385 @return () -> Zone?
13861386]=]
13871387function Observer .iterZones (self : Types .InternalObserver ): () -> Types .Zone ?
1388- local zoneId = nil
1389- local attachedList = nil
1388+ local zoneId : number ?
1389+ local attachedList : { number }
13901390 local observerId = self .id
13911391
13921392 return function (): Types .Zone ?
@@ -1397,11 +1397,11 @@ function Observer.iterZones(self: Types.InternalObserver): () -> Types.Zone?
13971397 return nil
13981398 end
13991399
1400- if not table.find (attachedList , observerId ) then
1400+ if not table.find (attachedList :: { number } , observerId ) then
14011401 continue
14021402 end
14031403
1404- local zone = State .zoneIdToZoneObj [zoneId ]
1404+ local zone = State .zoneIdToZoneObj [zoneId :: number ]
14051405 if zone then
14061406 return zone
14071407 end
@@ -1417,8 +1417,8 @@ end
14171417 @return () -> Group?
14181418]=]
14191419function Observer .iterGroups (self : Types .InternalObserver ): () -> Types .Group ?
1420- local groupId = nil
1421- local observersMap = nil
1420+ local groupId : number ?
1421+ local observersMap : { [ number ]: boolean }
14221422 local observerId = self .id
14231423
14241424 return function (): Types .Group ?
@@ -1433,7 +1433,7 @@ function Observer.iterGroups(self: Types.InternalObserver): () -> Types.Group?
14331433 continue
14341434 end
14351435
1436- local group = State .groups [groupId ]
1436+ local group = State .groups [groupId :: number ]
14371437 if group then
14381438 return group
14391439 end
@@ -1450,18 +1450,18 @@ end
14501450 @return () -> (Entity?, Zone?)
14511451]=]
14521452function Observer .iterEntitiesInside (self : Types .InternalObserver ): () -> (any ? , Types .Zone ? )
1453- local entities = State .observerTrackingEntities [self .id ]
1454- local entity = nil
1453+ local entities = ( State .observerTrackingEntities [self .id ] or {}) :: { [ Types . Entity ]: boolean }
1454+ local entity : Types . Entity ?
14551455 local observerId = self .id
14561456
14571457 return function ()
14581458 while true do
1459- entity = next (entities , entity )
1459+ entity = next (entities :: any , entity )
14601460 if not entity then
14611461 return nil
14621462 end
14631463
1464- local data = State .entityData [entity ]
1464+ local data = State .entityData [entity :: Types . Entity ]
14651465 if not data then
14661466 continue
14671467 end
@@ -1471,7 +1471,7 @@ function Observer.iterEntitiesInside(self: Types.InternalObserver): () -> (any?,
14711471 continue
14721472 end
14731473
1474- local ref = State .entityToReference [entity ] or entity
1474+ local ref = State .entityToReference [entity :: Types . Entity ] or entity
14751475 return ref , State .zoneIdToZoneObj [zoneId ]
14761476 end
14771477 end
@@ -1486,18 +1486,18 @@ end
14861486 @return () -> (Player?, Zone?)
14871487]=]
14881488function Observer .iterPlayersInside (self : Types .InternalObserver ): () -> (Player ? , Types .Zone ? )
1489- local entities = State .observerTrackingEntities [self .id ]
1490- local entity = nil
1489+ local entities = ( State .observerTrackingEntities [self .id ] or {}) :: { [ Types . Entity ]: boolean }
1490+ local entity : Types . Entity ?
14911491 local observerId = self .id
14921492
14931493 return function ()
14941494 while true do
1495- entity = next (entities , entity )
1495+ entity = next (entities :: any , entity )
14961496 if not entity then
1497- return nil
1497+ return nil , nil
14981498 end
14991499
1500- local data = State .entityData [entity ]
1500+ local data = State .entityData [entity :: Types . Entity ]
15011501 if not data then
15021502 continue
15031503 end
@@ -1507,7 +1507,7 @@ function Observer.iterPlayersInside(self: Types.InternalObserver): () -> (Player
15071507 continue
15081508 end
15091509
1510- local ref = State .entityToReference [entity ] or entity
1510+ local ref = State .entityToReference [entity :: Types . Entity ] or entity
15111511 if typeof (ref ) == 'Instance' and ref :IsA ('Player' ) then
15121512 return ref , State .zoneIdToZoneObj [zoneId ]
15131513 end
@@ -1532,24 +1532,24 @@ function Observer.iterEntitiesInZone(self: Types.InternalObserver, zone: Types.Z
15321532 end
15331533 end
15341534
1535- local entity = nil
1535+ local entity : Types . Entity ?
15361536 local targetZoneId = zone :getId ()
15371537 local observerId = self .id
15381538
15391539 return function (): Types .Entity ?
15401540 while true do
1541- entity = next (entities , entity )
1541+ entity = next (entities :: any , entity )
15421542 if not entity then
15431543 return nil
15441544 end
15451545
1546- local data = State .entityData [entity ]
1546+ local data = State .entityData [entity :: Types . Entity ]
15471547
15481548 if not data or data .activeObserverMemberships [observerId ] ~= targetZoneId then
15491549 continue
15501550 end
15511551
1552- return State .entityToReference [entity ] or entity
1552+ return State .entityToReference [entity :: Types . Entity ] or entity
15531553 end
15541554 end
15551555end
@@ -1571,24 +1571,24 @@ function Observer.iterPlayersInZone(self: Types.InternalObserver, zone: Types.Zo
15711571 end
15721572 end
15731573
1574- local entity = nil
1574+ local entity : Types . Entity ?
15751575 local targetZoneId = zone :getId ()
15761576 local observerId = self .id
15771577
15781578 return function (): Player ?
15791579 while true do
1580- entity = next (entities , entity )
1580+ entity = next (entities :: any , entity )
15811581 if not entity then
15821582 return nil
15831583 end
15841584
1585- local data = State .entityData [entity ]
1585+ local data = State .entityData [entity :: Types . Entity ]
15861586
15871587 if not data or data .activeObserverMemberships [observerId ] ~= targetZoneId then
15881588 continue
15891589 end
15901590
1591- local ref = State .entityToReference [entity ] or entity
1591+ local ref = State .entityToReference [entity :: Types . Entity ] or entity
15921592 if typeof (ref ) == 'Instance' and ref :IsA ('Player' ) then
15931593 return ref
15941594 end
0 commit comments