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 a model face an enemy?

I'm creating a tower defense game and need the towers to face the enemies so they can shoot them. I already have the magnitude and stuff made, I just need to know how to make the towers face the enemies.

Here's what I tried but it did not work:

turret.Center.CFrame = CFrame.new(turret.Center.Position, turret.Center.Position + enemy.CFrame.lookVector)

1 answer

✓ Accepted answer

You're using the correct constructor (CFrame.new(position, lookAt)). You're just making it a bit too complicated.

That constructor automatically creates a CFrame at position, pointing towards lookAt. Therefore your solution is as simple as:

part.CFrame = CFrame.new(part.Position, enemy.Position)

The constructor does all the hard work for you.

2 comments

0

Dear lord, I spent nearly an hour looking around the internet to find a solution to this. I can't believe it was this simple. Thank you!

0

:P

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