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 make a part point to another part?

Basically I want a part to rotate so it looks like it's pointing to another one, like an arrow. How do I make something like that?

2 comments

0

Use Body Gyro and Body Position.

0

it would be cool if you provided a further explanation

1 answer

There are many methods to rotating parts relative to an arbitrary position or object. For the sake of time and simplicity, we'll manipulate the part using CFrames.

When two Vector3's are inputted into a new CFrame construction, like so:

CFrame.new(vector3One, vector3Two)

The CFrame will contain a position at vector3One, and would rotate itself to look at vector3Two.

So to put this together in the context of two parts, you'd retrieve the Positions of the two objects, plug the values into the CFrame function mentioned above, and set the CFrame of the part you wanted rotated to the returned value. It should all look something like this:

local part = workspace.Part1
local pos1 = part.Position
local pos2 = workspace.Part2.Position

local newCFrame = CFrame.new(pos1, pos2)

part.Position = newCFrame

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