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

[Solved]How do I make a part (that is an active camera) follow the player when the player moves?

Asked by 4 years ago
Edited 4 years ago

I have tried getting the character move direction and change the camera position.

This code is in StarterCharacterScripts(folder)

--Code

01local currentCam = game.Workspace.CurrentCamera
02local camPart = game.Workspace.Cam
03local player = game.Players.LocalPlayer
04local character = player.Character
05currentCam.CameraType = Enum.CameraType.Scriptable
06repeat wait()
07    print("FIXING")
08    currentCam.CameraType = Enum.CameraType.Scriptable
09until currentCam.CameraType == Enum.CameraType.Scriptable
10print("FIXED")
11currentCam.CFrame = camPart.CFrame
12 
13while wait(0.1) do
14    currentCam.CFrame = camPart.CFrame
15    if character.Humanoid.MoveDirection == Vector3.new(1, 0, 0) then
16        camPart.Position = character.HumanoidRootPart.Position + Vector3.new(1, 0, 0)
17    end
18end
0
Also if you have the answer can you explain to me(It would be helpful for me in the future) PurpleSouley1234 43 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

--i have solved this myself

local currentCam = game.Workspace.CurrentCamera local camPart = game.Workspace.Cam local player = game.Players.LocalPlayer local character = player.Character currentCam.CameraType = Enum.CameraType.Scriptable repeat wait() print("FIXING") currentCam.CameraType = Enum.CameraType.Scriptable until currentCam.CameraType == Enum.CameraType.Scriptable print("FIXED") currentCam.CFrame = camPart.CFrame

while wait() do currentCam.CFrame = camPart.CFrame camPart.Position = character.Head.Position + Vector3.new(0, 0, 20) end

Ad

Answer this question