What's the best way to go about a "ghost mode"?

Right now im working on making a “ghost mode” for my game (i.e. you cant interact with players who are alive and can just move around the map)

Currently, my plan is to have 2 CollisionGroups, one for ghosts and one for regular players, and make them unable to collide with each other. Once the player wants to enter ghost mode, all of their parts will be added to the Ghost CollisionGroup and they will be teleported to the map. While in Ghost Mode, all of their parts will be set to 1 Transparency on the server and 0.75 on the client. The client will also set CanTouch on all the parts to false (to make the player unable to pick up tools)

Before i actually make this i was just wondering if anyone knew any ways that would be more efficient

thats probably the best way ngl

(in my own personal opinion)

Do the collision grouping. But, differ at the server part.

Tag their Character via CollectionService with like ‘Ghost’. We use CollectionService so you can account for streaming enabled via :GetInstanceAddedSignal(tag).

Then, on all clients, use render tie-in with RunService:BindToRenderStep() that sets the current tagged characters’ BasePart’s LocalTransparencyModifier (this is a hidden property a lot of people don’t know exists) to 1 if its someone else’s character, and then to 0.75 if it’s their own character.

-- inside BindToRenderStep...

for _, tagged in TaggedCharacters do
  local ours = (client.Character == tagged)

  for _, bp in tagged:GetDescendants() do
    if bp:IsA("BasePart") then
      bp.LocalTransparencyModifier = ours and 0.75 or 1
    end
  end
end
1 Like

Spawn the character only on the client. The server shouldn’t even spawn in the “ghosts”.

Unless you really need some sort of interaction between ghosts and the environment, just spawn the ghost in on the client.

honestly i didnt even know you could do that lol

will other players be able to see the ghost’s character or will they just not have one from other clients’ perspective?

The only person who has the ghost is the local player. But if your game has streaming enabled, you might have to send ghost positions to the server to tell the server to stream around the ghost’s position.

oh ok thats perfect, ill try that out

i dont think its spawning in anything except just tagging it, its still the player’s character. you’re gonna see odd behavior setting the character during runtime like this that i think is unnecessary.

Character management would need to be rewritten because LoadCharacter does not work on the client at all, however I think that this is a better approach for server performance.

You also wouldn’t set Player.Character. Just insert all the scripts yourself and edit the PlayerModule. Then, lastly, you wouldn’t even need to change CameraModule, you can just set the subject to the humanoid.

ok im gonna actually make the ghost mode now, thanks for the ideas

i liked @SubtotalAnt8185 's idea until i read “edit the PlayerModule” and i’d rather not do all that for how simple my game is lol

and @InfiniteYield 's idea is better than setting the transparency differently on the server and client (im not sure how i didnt think of this lol)

make sure to mark a solution :smiling_imp: so the thread closes, have a nice day

i ended up scrapping the ghost mode idea altogether xd

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.