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 3 years ago
Edited 3 years ago

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

This code is in StarterCharacterScripts(folder)

--Code

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(0.1) do
    currentCam.CFrame = camPart.CFrame
    if character.Humanoid.MoveDirection == Vector3.new(1, 0, 0) then
        camPart.Position = character.HumanoidRootPart.Position + Vector3.new(1, 0, 0)
    end
end
0
Also if you have the answer can you explain to me(It would be helpful for me in the future) PurpleSouley1234 43 — 3y

1 answer

Log in to vote
0
Answered by 3 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