Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Camera manipulation script is not working? [Answered]

Once again, my script has NO errors in the output.

It works PERFECTLY in studio, but not in a server/online.

Here's the script:

local target = workspace.CameraJoin
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target

game.Players.PlayerAdded:connect(function()
	while true do
		wait()
		camera.CoordinateFrame = CFrame.new(target.Position)
		camera.Focus = CFrame.new(game.Workspace.CameraFocus.Position)
	end
end)

This script is in workspace!

3 comments

0

You can't edit the CurrentCamera in a server script, you must use a LocalScript.

0

Well that was simple!

0

I'll add my comment as an answer and edit to see fit.

1 answer

✓ Accepted answer

You can't edit the CurrentCamera in a server script, you must use a LocalScript.

What I would do is create a LocalScript with the code to change the camera, get rid of the PlayerAdded stuff except for the camera changing code and then put it somewhere in the player.

So, you could have this as a LocalScript inside of StarterPack with the following code:

local target = workspace.CameraJoin
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target

while wait() do
	camera.CoordinateFrame = CFrame.new(target.Position)
	camera.Focus = CFrame.new(game.Workspace.CameraFocus.Position)
end

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

This discussion is preserved as it was. New answers, comments, and votes are closed.