Hey guys, I've been wondering for a while now how one would go about creating a script which would allow a single player to see through walls, while others are still incapable of doing so. This capability is seen in a few stealth-oriented games such as The Last of Us (Joel's listening mode), Dishonored (Corvo's Dark Listening mode), etc.
I'm not asking for the script, but for some help on the concept itself. If you have any ideas and decide to share them, I'd greatly appreciate it :).
One way of doing this is to put a SurfaceGui inside the PlayerGui, and set it's Adornee to the specific wall/block. You could then use scripts to decide which players are allowed to see through it or not, by making a frame visible/invisible.
This script would go inside the SurfaceGui:
script.Parent.Adornee = game.Workspace.Wall --Change this if you need to.
I'm not sure what type of game you're making, but that's all you really need anyways. Now you would just need to put a frame into the SurfaceGui that covers the entire wall, and make it invisible or visible depending on certain factors in your game.
If you need me to elaborate more on how you would go about this, leave a comment below, and I'll see what I can do. Anyways, hope I helped :P
You could go with the simple method and having the entire game be copied locally in the players thus adding the options to see through the walls whilst others cannot.
I think the best option would to insert parts into the player's Camera. The problem with this method is you have to use a script to generate the part for certain players. So in other words every time that player respawns you will have to have code that creates the part for that player again. Which means positioning, scaling, rotating, and all the other details just to have it local to the player. But it would work. Here's an example:
--LOCALSCRIPT! Put this in the backpack or startergui and it should work fine. DO NOT USE A NORMAL SCRIPT!! local Player = game.Players.LocalPlayer --Get the player local Permission = true --This is just for the example. If it is true then the player can walk through the wall, and vise versa. local part = Instance.new("Part") if not Permission then part.CanCollide = true part.Transparency = 0 elseif Permission then part.CanCollide = false part.Transparency = 0.75 end part.Anchored = true part.Position = Vector3.new(10, 5, 43) part.Size = Vector3.new(10, 10, 1) part.Reflectance = 0.5 part.Parent = game.Workspace.CurrentCamera --VERY IMPORTANT!
Remember, it's only an example. It's not what you would want exactly. It's just to give you an idea of what to do.