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

How would i make a model look at an moving enemy?

I am currently making a tower defense game, and my towers are supposed to aim towards the enemy(its moving along the track) everything in the game is finished, but im stuck on this question and cannot find anything to help.

2 comments

0

Maybe something to do with CFrame, rotation and or look vector?

0

Well, im not fond with CFrame or vector3

1 answer

✓ Accepted answer

Here is your script! (Served hot and ready to go)

local enemy = workspace.enemy1 -- you could change this to loop over the enemies to find closest one.
local me = script.Parent
while true do
	me:SetPrimaryPartCFrame(CFrame.new(me.PrimaryPart.Position, enemy.Position))   -- there are different types of cframe, this one looks at the point.
	wait()
end

if you need more info:

link

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