what im trying to do is very simple, and hopefully theres an answer, in my game i have a region that spawns npcs, those npcs attack, patrol, etc.
and as you know in replication the server will send the information of the npcs to all clients, but thats my issue, i DONT want the server to replicate to ALL clients, because in certain situations a client may be VERY far away from the npc or not able to interact with it at all, making the replication useless and only takes up bandwidth for no reason
so how can i just basically stop the server from replicating to the client for specific objects or objects in general that are far from the player, from what i understand there isnt a clear solution, but ive heard that streamingEnabled may fix it but i really didnt fully understand how it works, and from what i saw in the developer forum, it creates a lot of other restrictions in my game, but i guess if its the only solution then i might have to do it anways
from what i understand the issue with that fix is the server will continue with replicating because in its perspective, it sees that the npc is still existing in workspace so it replicates to that client as if nothing happened, and im pretty sure that it may still continue on updating on the client because theres a reference for the instance, its just that the parent is nil
you can do this via the streaming enabled property in workspace, although it should be enabled by default. it does modify scripts somewhat, but only local scripts. it’s not exactly a big hassle to overcome
i see, ill try it out, weirdly its not turned on for me, thanks for your help, just for the possibility of an another solution ill keep this forum open
Just create a Camera instance in the server, parent your instance to that, and parent the camera anywhere which normally replicates to the client. The camera is excluded from being replicated, so any of its descendants will also be excluded from being replicated.
Rereading the post again, it looks like my ADHD strikes again.
If you want clients that are far away from the NPC not to receive the data, for each player you can just calculate the distance of their character’s root part to the NPC’s root part in the server script before sending the data. The calculation is pretty simple and won’t affect performance if not done very excessively. It’s as simple as (playerRootPart.Position - npcRootPart.Position).Magnitude
You can send data via RemoteEvents specifically to a player by using event:FireClient(targetPlayer, …) instead of event:FireAllClients(…)