Why doesn't my Current Camera work?

How can I create a script for this current camera to work?
The Issue is that these code which is in “ServerScriptService” doesn’t want to work.

The code is

    if game.Players.PlayerAdded then
local CurrentCam = workspace.CurrentCamera
local StartCam = workspace.StarterCamera
function ChangeMode()
		repeat
		wait()
	CurrentCam.CameraType = Enum.CameraType.Scriptable
	until 
	CurrentCam.CameraType ~= Enum.CameraType.Scriptable

end
function ChangeCamera()
	repeat
		wait()
	CurrentCam.CameraSubject = StartCam
	until CurrentCam.CameraSubject == StartCam

	end

ChangeMode()
ChangeCamera()
end

I have already tried printing if the code works or not and apparently it gave me an answer that it was working fine but when I manually checked the property of the Camera in Workspace it did not change.

The server does not have a concept of a viewport. CurrentCamera is intended for modification by a LocalScript only. In addition to this there’s a few other misconceptions you have about your code. Consider doing a little bit of API research on the Developer Hub and some debugging.

  • PlayerAdded is a signal not a property or a boolean. You’re meant to connect functions to this that will run when the signal fires. PlayerAdded fires when a player joins the server. In the context of a LocalScript you will not need to use PlayerAdded to update the CameraType.

  • StarterCamera is not a property of the Workspace. Doesn’t exist.

  • CameraSubject is intended to either be a part or a Humanoid not another camera.

2 Likes