hewo, I have a script which player controls the NPC, but I have no idea how to make to camera go to the NPC too. anyways how to do that?
and how do i switch the control and camera back to the player?
heres the script:
local Character = script.Parent
local Npc = game.Workspace.Npc
UIS.InputBegan:Connect(function(Key, Chatted)
if Chatted then
return
end
if Key.KeyCode == Enum.KeyCode.E then
local Player = game.Players.LocalPlayer
Player.Character = Npc
end
end)
3 Likes
Please help me, I’ve tried a lot of camera scripts and none of them worked ;-;
Camera.CameraSubject might be what you are looking for.
Set the value to the Humanoid of the NPC to focus the camera on the NPC.
like this?
local Character = script.Parent
local Npc = game.Workspace.Npc
local Camera = game.StarterPlayer.CameraMode
UIS.InputBegan:Connect(function(Key, Chatted)
if Chatted then
return
end
if Key.KeyCode == Enum.KeyCode.E then
local Player = game.Players.LocalPlayer
Player.Character = Npc
Camera.CameraSubject = Npc
end
end)
i hve no idea how the camera subject. works, can you give me an exaample?
Definitely not looking up what CameraSubject is
Try changing the Camera.CameraSubject = npc to:
Camera.CameraSubject = Npc.Humanoid
Also use the workspace.CurrentCamera when defining your Camera, I don’t think you can do it like that?
Each camera has it’s own CFrame. In most cases, or at least how much I’ve seen, modifying the local player’s camera CFrame will do the trick.
It’s best for you to do some research on this yourself, but overall what you need to know is:
- What are CFrames?
- How can you modify a Camera’s CFrame? (Hint: CameraType)
- And the optional part: how to smoothly animate the transition a.k.a Tweens
2 Likes