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

How could I improve my script for making the camera face my npc?

Asked by 4 years ago

Here is my script why won’t it work?

Local target = workspace.npc Local camera = workspace.currentcamera

This doesn’t work I’m trying to make it follow this npc for a period of time

0
This is completely wrong isn’t it Eyelesstiamat 7 — 4y
0
That should help you out ^ DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Firstly, let's organize the script using that little blue button on top of your text box area.

local npc = workspace.npc
local Camera = workspace.CurrentCamera --Try to use `local` not `Local`.
Camera.CameraType = Enum.CameraType.Scriptable -- This makes sure the camera is scriptable and able to manipulate.

Now, if you want to make a camera face something or someone instantly, you can do;

Camera.CFrame = npc.Head.CFrame

However, if you wanted to make it smoothly transition to the npc's head, then do;

--Make sure to add a part where you want the camera to be looking from to looking at.
--I'll call the part "LookPart"
Camera:Interpolate(workspace.LookPart.CFrame,npc.Head.CFrame,0.5) --< Change the number according to how fast you want it to be.
--The first arguement of the `Interpolate` function is where the camera will look from.
--The second arguement represents where you want to look at.

I hope I helped!

Ad

Answer this question