I was wondering if there was a way I can get all NPCs in a client script? Basically NPCs get added and removed all the time and they all cant be parented to the same folder so thats out of the question. I was thinking originally since I gotta get them all on the client and all NPCs share the same module script to be setup I could fire to all clients in the setup module to say a new character was added and pass that character through but 2 issues come from that.
StreamingEnabled could make it return nil when passed through an event if I remember correctly.
What happens when a player joins AFTER the event fires?
What should I do? All help is greatly appreciated.
For your RemoteEvent solution you could create a remote that gets all currently spawned NPCS. For that you’ll need to keep track of them in a table on the server. And for the nil problem you could just make the NPCS persistent or ignore the nil’s. Depending on what you need the NPC’s for you could also just get their position from the server instead of the whole model.
Another solution would be to use a folder of ObjectValue’s that hold the NPCS and are added/removed when an NPC is added or removed.
Another thing you could do is add an Attribute or an instance to the NPC’s that differentiates them from everything else and dynamically handle whatever you need to do on the client to all the loaded NPC’s.