Making certain players invisible depending on their group/environment (client sided)?

I understand how to make players invisible locally on a single client via iterating through the the player’s character and making BaseParts transparent, but I also found another method in which the client reparents another player’s character to (let’s say) Lighting - and then back to the workspace to make them visible again.

However, I am struggling to gather a guide in which I can achieve the following example:

  1. Players have a main hub, and individual worlds branching out of that main hub.
    Players in the main hub can see other players also in the main hub, but cannot see any players outside of the main hub.
  2. When a player enters their world, all players within the main hub as well as players in other worlds become invisible (so that exploiters who aren’t suppose to be there can’t just fly over to their world and interfere with that player)
  3. When a new player enters their world, they become visible to the initial player and the entering player can see all those who are in that world except those who aren’t suppose to be there.

In short, players can only see other players who are currently sharing the same environment. The game will not include TeleportService since these worlds are just mini environments that is locally rendered by the appropriate players. I guess the closest comparison would be games like Adopt Me and Welcome to Bloxburg.

The game is a type of world sharing/role playing concept where there could be around 50 players in each game, so ideally for performance reasons, reparent other player’s characters that they do not have to see.

An issue I feel like that could make this more difficult to achieve is StreamingEnabled, a client may not even recognise another player’s character if it’s not within streaming range (correct me if I’m wrong).

Any guidance on how to achieve this would be fantastic, thanks!

This is the first thought my exhausted brain came up with:

Have some sort of value stored for each player on the server. When a player joins or switches worlds then loop through them, if they are in the same world then check if they are need to be loaded again and make that user visible. If they aren’t in the same world then just set them invisible.

You may also try to parent the characters to lighting if you want, I myself haven’t tested that out and I will not today. Although It does seem like more performant to me. You can also use this same technique to load and unload worlds. It may be what I end up using for my game too.

1 Like

I’ll have a look into this method! Although the issue regarding StreamingEnabled is still present, I haven’t tested it myself since its very difficult to force unloading stuff, just concerned whether or not players characters are indefinitely accessible regardless if they are in a place that is within streaming range.

I thought of a little method in which I can parent characters to folders within workspace, since folders are guaranteed to be accessible by the client, and just reparent the folder itself. Will need to extensively test this.

Ah I see. I myself haven’t tested this method out inside of Roblox yet, only Unity and my head. So It may or may not work, it’s really only something I thought about when faced with your exact problem.

1 Like