Im currently working on a Projectile System and I created this:
RunService.Heartbeat:Connect(function(DeltaTime:number)
for _, Object in Projectiles do
-- // Move //
if Object.Health > 0 and Object.Part then
if not Object.Part.Parent then continue end
local Direction:CFrame = Directions[Object.Direction] or Directions.Forwards
local Speed = Object.Speed * DeltaTime
local TravelTo = (Direction * CFrame.new(Speed, Speed, Speed))
-- // Move //
if Object.Distance > Object.Range then
-- // Drop Off //
end
Object.Part.CFrame *= TravelTo
Object.Hitbox:CheckForCollisions()
end
end
end)
the idea is that it should move the Object.Part forwards.
The problem is that they kinda go up and to the side, I assume I did something wrong with the TravelTo CFrame, as when the speed is 0, making the TravelTo just a blank CFrame, it works perfectly fine.
So how can I fix this?
Also, these are the Direction that are mentioned in the script
return {
['Forwards'] = CFrame.new(0,0,-1),
['Backwards'] = CFrame.new(0,0,1)
}