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

How do I get the Camera to follow a certain part?

I'm a fairly experienced scripter, except I haven't really worked with the Camera in ROBLOX a lot.

So what I want to do, is get the Camera to follow a certain brick. Meaning every time the brick moves, the camera will move in unison. Also, I know that the CameraScript works 100% correctly, I just need to make the camera follow the CamPart in the LocalScript. Here's what I have so far:

Script Hierarchy:

Game

--Workspace

----CameraScript (Script)

------LocalScript (LocalScript)

Part I want to follow Hierarchy:

Game

--Workspace

----Model (Model)

------Part (Part)

------Part (Part)

------CamPart (Part)

CameraScript code:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		repeat wait() until character
		
		script.LocalScript:clone().Parent = character
		
		for i,v in pairs(character:GetChildren()) do
			if v.ClassName == "Part" then
				v.Anchored = true
			end
		end
	end)
end)

LocalScript Code (so far):

local cam = game.Workspace.CurrentCamera

cam.CameraType = "Scriptable"
cam.CameraSubject = game.Workspace:FindFirstChild("Model").CamPart

(The camera is set to "Scriptable" so that rotation of the camera by the users mouse is disabled)

1 comment

0

bump

1 answer

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