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

How do you make a part that is only visible for you?

Asked by 9 years ago

Do you make a local script? like this.

local part = Instance.New(Part)
part.Parent = game.Workspace
part.Position =  --Something.Position

1 answer

Log in to vote
4
Answered by 9 years ago

I believe the term you're looking for is local parts. Local parts are parts that are only visible to you, which nobody else can see.

There are a few ways you can create local parts. All methods of creating local parts require you to use a LocalScript, so make sure you're using a LocalScript for making a local part.


FilteringEnabled:

FilteringEnabled is a property recently added to Workspace that is mainly used to stop hackers. FilteringEnabled's main feature is that anything created on the client is only replicated on the client, meaning if you create a part in Workspace with a LocalScript, it will only be visible to you. This allows for the creation of local parts.

To enable this feature, click on Workspace in Studio's Explorer window and check the FilteringEnabled box in the properties window.

FilteringEnabled does have some drawbacks that could affect a lot of your scripts in game, which you can learn more about here.

Once you have FilteringEnabled turned on, create a part in Workspace and it should only be visible to you in game.


Camera:

Putting an object into a Camera from a LocalScript allows you to create local parts. This is because cameras are only replicated to the client, similar to how FilteringEnabled only replicates to the client, except that you can replicate to the client normally via a LocalScript unlike FilteringEnabled.

You can either create a part in the CurrentCamera using workspace.CurrentCamera, which is the player's camera or you can create a new Camera and stick all your parts in there.

The drawback to making local parts in a Camera is that scripts, local or not, inside the part and it's children will not run in the Camera. You will need to handle scripts for local parts outside of the camera and reference the part directly in your script.

CurrentCamera code:

local part = Instance.new("Part")
part.Parent = workspace.CurrentCamera --Puts the part in the player's camera.

New Camera code:

local cam = workspace:FindFirstChild("LocalStorage")
if not cam then
    cam = Instance.new("Camera", workspace) --Creates a new camera in workspace.
    cam.Name = "LocalStorage" --Name the camera to something suitable.
end

local part = Instance.new("Part")
part.Parent = cam --Place part in the camera.

Message:

You can also use a Message that's inside the player's character instead of a Camera.

The advantage to doing this is that the parts are not picked up by the player's mouse, so you could use it to create a 3D custom mouse cursor. However, all the parts are removed when the character respawns, so you'll need to create them again after the character respawns.

It is the same method as creating a new camera, except you don't use a Camera and you change the parent to the player's character.


Potential drawbacks:

There are a few potential drawbacks when using local parts.

One drawback is that local parts are not officially supported by ROBLOX. The dev team could release an update which changes how Messages/Cameras work so you can't create local parts, which means you then have to use FilteringEnabled in order to create local parts.

Another drawback is that the physics of local parts may run weirdly and may glitch. This usually does not happen but I advise you to take note of this as it could happen depending on what you want to do with local parts.

The final drawback is that they will not react to objects in the server, such as NPCs. This could be more of a benefit than a drawback but if you're relying on server objects interacting with local parts, you will need to use FilteringEnabled.


I hope my answer helped you. If it did, be sure to accept it.

Ad

Answer this question