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

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

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.

Ad

Answer this question