Hello,
I’m trying to implement a Part that searches for nearby players. I want to use CollectionService to tag parts that will have this functionality. Here is my code:
local CollectionService = game:GetService("CollectionService")
local function lookForPlayers(enemy)
while true do
print(enemy)
--lf players: raycast, proximity check, etc
wait(1)
end
end
CollectionService:GetInstanceAddedSignal("Enemy"):Connect(function(enemy)
local f = coroutine.wrap(lookForPlayers)
f(enemy)
end)
Is this a good implementation? How performant is this compared to other solutions?
Thanks