Point:
The point of this weapon is to fire a projectile in a straight line from the barrel to whatever is in front of it. Pretty simple I suppose.
Problem:
The projectile seems to be flying downwards even though it’s set up to fly straight out of the barrel. I don’t know if I’m missing something, or overlooking an issue in the code or what. Any Help is greatly appreciated.
I’ve tried changing the CFrame to different things and nothing really seems to solve the issue.
https://gyazo.com/7283f014e9fbe9d918fcaa39a4901fff
https://gyazo.com/2454e083af47054d39d057e5b3ebd420
As you can see, the projectile flies a little below the barrel.
Code:
function module.fireProjectile(car, gun, player)
local damage = damages[gun.Name]
if damage then
local projectile = script.Asset_Storage.Bullet:Clone()
parentItem(projectile, damage, player)
local emitter = projectile.Fins:FindFirstChildWhichIsA("ParticleEmitter") or createEmitter(projectile.Fins)
local bodyForce = Instance.new("BodyForce")
bodyForce.Force = gun.firePart.CFrame.LookVector * 175
bodyForce.Parent = projectile.Body1
emitter.Enabled = true
projectile.Body1.CFrame = CFrame.new(gun.firePart.Position, gun.AIMING.CFrame.LookVector) * CFrame.Angles(math.rad(-90), 0, 0)
projectile.Parent = workspace
end
end
The system is set up pretty simply, there’s a part that moves the barrel and such for aiming, and a firePart and that part is where the projectile will spawn.
The blue part is the firePart, and the red one AIMING.
The projectile is set up as so, everything is welded to Body1 and they’re all unanchored, and non-collidable MeshParts.
I really don’t know what to do at this point, any help is greatly appreciated. If I left out any missing bits, please let me know.