Retrieving CurrentCamera from a normal Script?
Asked by
8 years ago Edited 8 years ago
I know that you can retrieve the CurrentCamera
from a LocalScript
by doing this:
1 | local camera = game.Workspace.CurrentCamera |
However, I want to be able to get the CurrentCamera
in a normal Script
, specifically for one that is in StarterPlayer > StarterCharacterScripts.
I have tried using a RemoteFunction to retrieve it. This is the method that I used:
02 | game.Players.PlayerAdded:connect( function (player) |
03 | local getCamera = script:WaitForChild( "GetCamera" ):Clone() |
04 | getCamera.Parent = player |
05 | getCamera:WaitForChild( "LocalScript" ).Disabled = false |
09 | function script.Parent.OnClientInvoke() |
10 | print ( "Getting camera..." ) |
11 | return game.Workspace.CurrentCamera |
15 | local player = game.Players:GetPlayerFromCharacter(script.Parent) |
16 | print (player:FindFirstChild( "GetCamera" ) ~ = nil ) |
17 | local camera = player:FindFirstChild( "GetCamera" ):InvokeClient(player) |
18 | print ( "Retrieved camera" ) |
So it is apparent that when I invoke the client to retrieve the CurrentCamera
, it yields the script right there. It doesn't even give any errors or anything. The script just pauses there. Is it possible to retrieve CurrentCamera
from a normal Script
at all, or am I doing something wrong in my method?