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

How do I make an anchored brick face a specific brick at all times?

Here is my orbit script. I need to modify it so that the part that orbits has a specific face constantly face a specified brick while orbiting.

Parent = script.Parent
Rotate = script.Parent.Parent.LeaderboardRotate

while wait() do
    local t = tick() * (math.pi * 2) * .1 -- 1.5 revolutions per second
    local orbit = Vector3.new( math.cos(t), 0, math.sin(t) )
    Parent.CFrame = CFrame.new( Rotate.Position + orbit * 7 )
end

"Parent" is the brick that is orbiting. "Rotate" is the brick it is orbiting.

2 comments

0

I'd just like to point out that Referring to script.Parent as "Parent", can cause issues

0

Wait about a day while I get my calculus book out. This involves rotation matrices.

1 answer

✓ Accepted answer

CFrame.new has a convenient constructor that takes two Vector3s, from and to and produces a CFrame looking from from and toward to.

For instance, the following will make Parent move the same way it did before, but always look towards Rotate:

Parent.CFrame = CFrame.new( Rotate.Position + orbit * 7, Rotate.Position )

By "towards", I mean the Front-face is pointing in the direction of the to, and the Top-face is roughly pointing up (as opposed to down, or left, or whatever)

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