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

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

Asked by 10 years ago

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)

0
bump McCorus 5 — 10y

1 answer

Log in to vote
0
Answered by 9 years ago

bumpp

Ad

Answer this question