Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Also if you have the answer can you explain to me(It would be helpful for me in the future)

1 answer

--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

This discussion is preserved as it was. New answers, comments, and votes are closed.