@@ -39,6 +39,7 @@ function Orb.Init()
3939 Orb .Attachments = {} -- (tostring(playerID) -> orb)
4040 Orb .ListeningStatus = {} -- Which players are listening to an orb? For halos (tostring(playerID) -> bool)
4141 Orb .OrbCamStatus = {} -- Which players are watching through orbcam? (tostring(playerID) -> bool)
42+ Orb .SpeakerLastMoved = {} -- (tostring(playerID) -> last move time)
4243
4344 local orbs = CollectionService :GetTagged (Config .ObjectTag )
4445 for _ , orb in ipairs (orbs ) do
@@ -76,6 +77,12 @@ function Orb.Init()
7677
7778 OrbSpeakerMovedRemoteEvent .OnServerEvent :Connect (function (plr , orb )
7879 if not plr .Character then return end
80+
81+ local lastMoveTime = Orb .SpeakerLastMoved [tostring (plr .UserId )]
82+ if lastMoveTime ~= nil and lastMoveTime > tick () - 5 then return end
83+
84+ Orb .SpeakerLastMoved [tostring (plr .UserId )] = tick ()
85+
7986 local playerPos = plr .Character .PrimaryPart .Position
8087
8188 local waypointPos = Orb .TweenOrbToNearPosition (orb , playerPos )
@@ -666,15 +673,15 @@ end
666673
667674function Orb .TweenOrbToNearPosition (orb , pos )
668675 local waypoints = CollectionService :GetTagged (Config .WaypointTag )
669-
670676 if # waypoints == 0 then return orb :GetPivot ().Position end
671677
672- -- Find the closest waypoint to the new position
673- -- and move the orb there
678+ -- Find the closest waypoint to the new position and move the orb there
674679 local minDistance = math.huge
675680 local minWaypoint = nil
676681
677682 for _ , waypoint in ipairs (waypoints ) do
683+ if not waypoint :IsDescendantOf (game .Workspace ) then continue end
684+
678685 local distance = (waypoint .Position - pos ).Magnitude
679686 if distance < minDistance then
680687 minDistance = distance
@@ -683,7 +690,6 @@ function Orb.TweenOrbToNearPosition(orb, pos)
683690 end
684691
685692 if minWaypoint ~= nil then
686- -- If we are already there, don't tween
687693 if (minWaypoint .Position - orb :GetPivot ().Position ).Magnitude < 0.01 then
688694 return orb :GetPivot ().Position
689695 end
@@ -723,16 +729,13 @@ function Orb.TweenOrbToNearPosition(orb, pos)
723729 OrbTweeningStopRemoteEvent :FireAllClients (orb )
724730 end )
725731
726- -- Note that if the position is already being tweened, this will
727- -- stop that tween and commence this one
728732 orbTween :Play ()
729-
730- -- Announce this tween to clients
731733 OrbTweeningStartRemoteEvent :FireAllClients (orb , minWaypoint , poi )
732734
733735 return minWaypoint .Position
734736 end
735737
738+ print (" [MetaOrb] Failed to find near waypoint" )
736739 return orb :GetPivot ().Position
737740end
738741
@@ -883,6 +886,7 @@ function Orb.PointOfInterest(targetPos)
883886 for _ , family in ipairs (families ) do
884887 for _ , p in ipairs (family ) do
885888 if CollectionService :HasTag (p , " metaboard_personal" ) then continue end
889+ if not p :IsDescendantOf (game .Workspace ) then continue end
886890
887891 local pos = p :GetPivot ().Position
888892
@@ -895,6 +899,10 @@ function Orb.PointOfInterest(targetPos)
895899 end
896900 end
897901
902+ if closestPoi == nil then
903+ print (" [MetaOrb] Failed to find closest point of interest" )
904+ end
905+
898906 return closestPoi , closestPos
899907end
900908
0 commit comments