Hello! I've recently come to a snag on this one missile heading script I've been working on. It technically works but it keeps going in circles instead of going toward the target. I've tried changing the radian? I'm not very good at CFrame math so I really don't know what I'm doing here. (partreg is a registry of important parts my game uses.)
local partreg = require(game.ServerScriptService.modules.partregistry)
while true do
wait()
for i,v in pairs(partreg.missiles) do
if v ~= nil then
local target = v:FindFirstChild('target')
if target then
local targeta = game.Workspace.ships:FindFirstChild(target.Value)
if targeta ~= nil then
local targetpart = targeta.body.PrimaryPart
local inital = v.CFrame
local final = CFrame.new(v.Position,targetpart.Position) * CFrame.Angles(math.pi/.001,0,0)
v.CFrame = inital:lerp(final,i)
local angle = CFrame.new(v.Position, targetpart.Position)
v.AssemblyLinearVelocity = v.CFrame.LookVector * 200
end
end
else
partreg.removepart("missiles",v)
end
end
end
