The CurrentCamera is a property of Workspace. But what is it? It is a link to an object, but what? The object is links to is a Camera. But it is the camera belonging to the local player. The words 'local player' brings out the fact that only LocalScripts 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 via LocalScript has the same effect.
Here's an example usage, that creates a part when a TextButton is pressed. This script is ran in a LocalScript 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 after the game is ran.
| Scripting (44) |
| ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| GUI (8) |
| ||||||||||
| Building (3) |
| ||||||||||
| Platform (8) |
| ||||||||||