Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I make parts and decals visible to one player?

Asked by
lucas4114 607 Moderation Voter
8 years ago

There are games like apoc that has a map that loads parts and makes them visible to the player seeing it, and theres miner's haven when placing an items others don't see it untill you place it and lots of other games do this. How do I make a part or a decal only visible to one player?

0
Local parts (parts in the camera) tkddude2 75 — 8y

2 answers

Log in to vote
7
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

What you're trying to achieve are Local Parts, which can be read all about in this wiki article. Local Parts only become visible to the specific player, and can only be done through local scripts. There are three ways to go about doing this.


CurrentCamera

This is a simple trick when FilteringEnabled is disabled. All you have to do is designate the part's parent to Workspace's CurrentCamera object. The code below will go over it basically.

Instance.new('Part', game.Workspace.CurrentCamera)

The script is creating a new part and placing it inside the CurrentCamera object.


Message

Apparently, you can add a Message object to your character, name it LocalBin, and it will supposedly work. I have not tried this method personally, but I would assume the part would get lost if you were to be respawned.

local bin = Instance.new('Message', game.Workspace.Player)
bin.Name = 'LocalBin'

local part = Instance.new('Part', bin)

The script is creating the Message object in the Player's Character and names it LocalBin. Once done with that, it inserts a part into the bin.


FilteringEnabled

Now this may be the easiest to do, however may be the hardest to convert to. As there are many scripts that modify the Player's Gui elements through Server Sided scripts that are not possible with FilteringEnabled Enabled. However if you're experienced and know how to modify your scripts to become FilteringEnabled compatible, do it. It is essentially ROBLOX's layer of protection and will end up making local parts easy in this case.

So, in workspace you would want to make sure the FilteringEnabled property is set to true, and then you can use a LocalScript to insert a part directly into workspace. With this you will not be affect other people's behaviors to the parts and they physically will not see it.

Instance.new('Part', game.Workspace)

Hopefully this helped, if so hit the upvote button. And if this answered your question do not forget to hit that Accept Answer button. If you have any questions or comments, leave them in the comments section below.
0
I've also noticed with putting parts in the player's model is they turn transparent when you zoom into first person, I haven't tryed this yet (the CurrentCamera one) but does that happen if I did it? lucas4114 607 — 8y
1
The current camera should not have that issue, but I have not tested it fully. That's interesting to know about the player's model one though I'll have to get around to testing that and see if that issue still occurs. Local Parts are not an official feature of ROBLOX and can be removed at anytime at their discretion, just keep that in mind. M39a9am3R 3210 — 8y
0
Hmm, ok. lucas4114 607 — 8y
0
Where does the script have to be and does it have to be a local script for CurrentCamera? lucas4114 607 — 8y
0
The script must be a local script. The LocalScript can be located in that Player's backpack, playergui, playerscripts, or character in order for them to work. M39a9am3R 3210 — 8y
Ad
Log in to vote
4
Answered by
Xoqex 75
8 years ago

Great question, I too, asked this one to myself the other day and came up with the answer.

In order to do a local part, or local anything (Including particles) it will require a local script What I did for mine: I put the local parts I wanted in a model and put that model in lighting. Then on player entered, I cloned that model and put the clone into game.Workspace.CurrentCamera

So say you want to have a stair case only you can see:

First, you create the model, place it where you want and cut and paste into lighting. After that you would do a script like this:

If you want to say, use admin commands to make it appear for you instead of onentered you could run this:

game.Lighting.Staircase:Clone().game.Workspace.CurrentCamera

That would work fine with an admin that can run local scripts, or if you want it in any server of your game without admin you could do this: Put local script in StarterGui, it forces the script to run every time you respawn or join a server; pretty much every time your character loads.

Now with this in StarterGui as a local script, it would make the staircase for only you, and other peoples will see you walking up air like a god.

if game.Players.LocalPlayer.Name ==("lucas4114") then game.Lighting.Staircase:Clone().game.Workspace.CurrentCamera
end

I can't this last one will work since I didn't write it in studio, but it should give you the idea.

And don't limit to cloning, you could use ~~~~~~~~~~~~~~~~~ Instance.new("ParticleEmitter",game.Workspace.CurrentCamera.ParticleBrick) ~~~~~~~~~~~~~~~~~

Just as long as its set to current camera :) Hope this helped.

Answer this question