Easiest way to hide Players from Server but not locally?

Hi, basically I’ve made a chunk loader that loads the chunks individually and locally, so when a player passes through to a new area, the old one is hidden and new is loaded etc.

Because of this though, other Players on the map can be seen floating on nothingness and was wondering if there was a way to hide these players unless they’re in the same chunk?

Thank you.

4 Likes

To hide player’s characters I just parent them locally to ReplicatedStorage and catch the .CharacterAdded event and reparent them there.

3 Likes

Hey can you elaborate?

My idea was having two folders - Server and client. Locally moving the Client folder on enter and parenting players to that unless they’re in the same chunk?

If you want to hide player characters, you should do this all in a LocalScript - you can’t do it on the Server.
Your LocalScript should load all the other player’s characters, and if they are not in the same chunk as the LocalPlayer, then you can parent them outside or workspace, and bring them back if they are in the same chunk.

Don’t do this on the server, because then the characters will be invisible to everyone, including the player.

3 Likes

@haash_im 's idea isn’t bad,

Maybe have the server parent them to RS, then use a local script to parent them back to the workspace

1 Like

Okay guys.

So, there’s two sections to the game - Space itself and the Planets.

With the Planets (interior if you will) being loaded locally, they are inserted into a Folder in Workspace called “Chunks” so the folder is empty other than when your player is in that chunk.

If the Players characters are loaded locally, how am I to detect if two Characters share the same chunk?

Sorry, not able to write up any code atm as am away from home.

You could simply check their positions or which chunk they are currently in? I assume you have a way to figure out which chunk they’ve left in order to hide that, so then you should be able to figure out their current chunk. You could check it on the client or the server, though the server is always the safest choice for these things. Can’t think of a reason off the VERY top of my head (i.e. haven’t put the most thought into it, just a minute) to use the client.

If you have a chunk loading system, then you don’t have the right mindset by involving the server. Chunk loading is a client-based operation. The server doesn’t need to render anything. Parenting characters or changing their transparency, if outside of a loaded chunk, is an appropriate go-to.

2 Likes

My mind set being Players are automatically loaded server side are they not?

Forgive the format and potential errors, this is without focus and tests.

Character parents are managed via Server, obviously if placed in Client they are not visible however being in Server are.

Thoughts?

Server

local Server = Instance.new("Folder", workspace) Server.Name = "S" 
local Client = Instance.new("Folder", workspace) Client.Name = "C" 

game.Players.PlayerAdded:Connect(function(NP)


NP.CharacterAdded:connect(function(NC)
NC.Parent = Server
end) 

end)

Client

if workspace:FindFirstChild("C") ~= nil then
Workspace["C"]:Destroy()
else end

If you had the server parent it to RS then it would happen for everyone, including the player you just put into RS. You can only do it on the client side so it just makes the player invisible and also doesn’t cause any gameplay problems

1 Like

I’ve had an idea of another way I could do this and that’s potentially using magnitude?

I can see if Players are within 1k studs of eachother and if so, display their characters? If not then obviously hide them client side.

Ideas of how I would go about this?

And this is how the final piece looks?

local RunService = game:GetService("RunService")

local Player = game.Players.LocalPlayer
local Character = Player.Character
if not Character or not Character.Parent then
    Character = Player.CharacterAdded:wait()
end

RunService.RenderStepped:Connect(function()
	
	for _,p in pairs (game.Players:GetChildren()) do
		if p then
			if p.Character then
			
			if (p.Character.HumanoidRootPart.Position - Character.HumanoidRootPart.Position).Magnitude < 50 then
				if p.Character.Parent == workspace then
				else
				p.Character.Parent = workspace
				end
			else
				if p.Character.Parent == game.ReplicatedStorage then
				else
				p.Character.Parent = game.ReplicatedStorage
				end
			end
			
			else end
		else end
	end
	
end)
GetPlayers() --Would recommend using this instead, as there are some things :GetChildren() returns that are not player objects and may cause .Character to throw an error.
end -- The elses here seem a bit un-necessary
end

I also might recommend, making an Individual folder for each “Planet/Chunk” and parenting said Player to the Chunk in which they reside server sided; then locally, you can have the folders Parented to and from workspace as the Player starts to load different chunks

Have the server put it in RS, have the client take it out

Turns out my issue was problematic, as with the magnitude the Player must be within the distance of where the other was removed in order to see them again, regardless if they’re standing next to them.

Any other ideas with explanations guys?