roblox
Tutorial page
This article is an advanced tutorial.
Scripting
This page is a tutorial about Scripting.

The CurrentCamera is a property of Workspace light iconWorkspace dark iconWorkspace. But what is it? It is a link to an object, but what? The object is links to is a Camera light iconCamera dark iconCamera. But it is the camera belonging to the local player. The words 'local player' brings out the fact that only LocalScript light iconLocalScript dark iconLocalScripts can access it. But editing the CurrentCamera is simple, and can enhance your game a lot.

Adding objects to it

Objects can easily be added to the current camera. When an object is parented to CurrentCamera, only the local player can see and interact with it. This can be useful for things such as gates that are only visible by certain players. This method is no longer recommended, since parenting objects to Workspace light iconWorkspace dark iconWorkspace via LocalScript light iconLocalScript dark iconLocalScript has the same effect.

Here's an example usage, that creates a part when a TextButton light iconTextButton dark iconTextButton is pressed. This script is ran in a LocalScript light iconLocalScript dark iconLocalScript inside the TextButton.

script.Parent.MouseButton1Click:Connect(function()
    local part = Instance.new("Part")
    part.Parent = game.Workspace.CurrentCamera
end)

Now this part only acts physics upon the LOCAL player. It is important to note that, objects placed in the Camera before the game starts will be destroyed. All objects that are placed into the CurrentCamera must be placed in from a LocalScript light iconLocalScript dark iconLocalScript after the game is ran.