Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Camera Script Not working?

Asked by 8 years ago

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

Log in to vote
0
Answered by
yelsew 205 Moderation Voter
8 years ago

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)
0
i tried both ways neither is working, or changing the players focus. pluginfactory 463 — 8y
0
Have you setup the variables? yelsew 205 — 8y
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. yelsew 205 — 8y
0
I tried both. no output. pluginfactory 463 — 8y
0
Hmmm... since I'm bit new to scripting, I don't know any other methods. Sorry. yelsew 205 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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.

0
that would just make an overlay pluginfactory 463 — 8y

Answer this question