Seperating Map into Instances?

I’m working on a RPG game that will feature several visitable Planets. These Planets will be loaded onto the Players Instance, Client Sided.

I have the basis covered, generating & loading the Planet etc. However, what I’m wondering is how to create Hostile NPCs that will be visible to those on the Planet only. This includes everyone present so that it does not seem as if Players are fighting nothing.

How could I work this?
Will update this thread as I go.

Depending on how complicated your AI/NPC model is you want to take a different approach.

Say it’s just a cube with no humanoid that sometimes shoots lasers at you, you could let the clients know to clone their own NPCs, which each via RemoteEvents continually get updates from the server on where to be, how much HP to display, who to attack, where to move, etc.

For more complicated models you might just want each player, that is not supposed to see them, destroy the NPCs right after they load in for everyone.

1 Like

Bouncing this idea back at you - Perhaps a LocalScript that detects whether an NPC has spawned ServerSide & if the CurrentChunk doesn’t match then the model is :Destroy?

However, if I were to do this then if someone were to join a Planet after NPCs have spawned, they won’t be visible?

Why not just parent the NPC to respective map that it belongs to?

That’s what I intended to say, yes.

That’s a very good point. Perhaps you can just make the models invisible instead of destroying them and then make them visible if you come close. It wouldn’t reduce strain on the client, but at least you cannot see them from far away.

You might want to look into StreamingEnabled as it could potentially do the entire load-unload thing for you, including the planets themselves.

I’ll take a look into that StreamingEnabled! Thing is, the Planets themselves are an entire Instance, and the ‘Space’ area is just shrank to give the illusion its larger.

Referring back to this, could a work around be generating a Folder for each individual Planet that the NPCs are parented to - This way, in a similar method, the Folder is moved to suches as ReplicatedStorage if not needed?