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

Camera Script Not working?

Idea I want to lock the players camera so that he is forced to look at the specified area Problem The problem is that the player is not focusing in the direction of the part, but the field of view is working.
Possibility I think that I am using focus, or I'm miss understanding it's use.
Code

plr = game.Players.LocalPlayer
Char = plr.Character
workspace.CurrentCamera.CameraType = "Scriptable"
workspace.CurrentCamera.FieldOfView = 10
workspace.CurrentCamera.Focus = game.Part1.Position

2 answers

✓ Accepted answer

How to Make a Camera Look in a Certain Direction

There are two ways to make a camera look in a certain direction. The first is using CFrames and Vector3s. The other is using Focus. Both ways work differently, and you may have to use one way over another.

How would I do it with CoordinateFrame?

To this with CFrame, you must edit the CoordinateFrame property of the CurrentCamera. Here is an example:

local camera = game.Workspace.Camera

camera.CameraType = Enum.CameraType.Scriptable

camera.CoordinateFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(x,y,z))

This sets the location and where the camera is facing in one short, convenient code block.

How would I do so with Focus?

You would set up your code with CurrentCamera.Focus, and you need to use CFrame again.

local camera = game.Workspace.CurrentCamera
local focuspart = game.Workspace.FocusPart --or whatever part you are trying to look at.

camera.CameraType = Enum.CameraType.Scriptable

camera.Focus = CFrame.new(focuspart.Position)

5 comments

0

i tried both ways neither is working, or changing the players focus.

0

Have you setup the variables?

0

The first method must be in a local script under StarterPlayer, and put it into that scripts folder inside there. The second must be put into serverscriptservice and must have your variables defined. Tell me the output please.

0

I tried both. no output.

0

Hmmm... since I'm bit new to scripting, I don't know any other methods. Sorry.

You don't need to involve a script, you can add a frame, size it to UDim2.new(1,0,1,0) and make the active property = true.

1 comment

0

that would just make an overlay

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