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)
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.