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

How to make a camera locate a part in my car?

I want to make the camera in "DriveScriptAWD"(Local) to locate

Car chassis is the parent of "Parts" and "DriverSeat"

"Parts" is the Parent of "CamFocus". "DriverSeat" is the Parent of "ToolGiver"

"ToolGiver" is the Parent of "DriveGui"

"DriveGUI" is the parent of "DriveScriptAWD"

I can't figure out how to locate "CamFocus" locally.

My script:

cam.CameraSubject = ???

How can I do this?

1 answer

If I understand you correctly, your Instance hierarchy is as follows:

--Car Chassis
------Parts
----------CamFocus
------DriverSeat
----------ToolGiver
--------------DriveGUI
------------------DriveScriptAWD

So:

cam.CameraSubject = script.Parent.Parent.Parent.Parent.Parts.CamFocus

But it would be better to make references to them so that it's easier to see what is going on:

driveGUI = script.Parent
toolGiver = driveGui.Parent
driverSeat = toolGiver.Parent
chassis = driverSeat.Parent
parts = chassis.Parts
focus = parts.CamFocus

cam.CameraSubject = focus

I hope that answers your question.

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