Is there a way to make a homing type projectile
This is basicly what i have going on but the Raycast is not getting updated so it jerkes around when it finds the target
function OnRayUpdated(cast, segmentOrigin, segmentDirection, length, segmentVelocity, cosmeticBulletObject)
-- Whenever the caster steps forward by one unit, this function is called.
-- The bullet argument is the same object passed into the fire function.
if cosmeticBulletObject == nil then return end
local bulletLength = cosmeticBulletObject.Size.Z / 2 -- This is used to move the bullet to the right spot based on a CFrame offset
local baseCFrame = CFrame.new(segmentOrigin, segmentOrigin + segmentDirection)
cosmeticBulletObject.CFrame = baseCFrame * CFrame.new(0, 0, -(length - bulletLength))
local t = cast.UserData["Target"]
local c = cast.UserData["Player"]
if(t == nil) then
for i,v in pairs(workspace:GetDescendants()) do
if(v:findFirstChild("Humanoid") and math.abs((v.HumanoidRootPart.Position - cosmeticBulletObject.Position).Magnitude) <= 15) then
cosmeticBulletObject.CFrame = CFrame.new(cosmeticBulletObject.Position,v.HumanoidRootPart.Position)
print(v)
end
end
end