Projectile is being fired is fired sideways

local bullet = game:GetService(“ReplicatedStorage”).Bullet2
local turret = script.Parent

local aggrodist = 250
local bullet_dmg = 5
local bullet_mag = 300
local reload_time = 0.1
local bullet_speed = 500

while wait(reload_time) do
local target = nil
for i,v in pairs(game.Workspace:GetChildren()) do
local human = v:FindFirstChild(“Humanoid”)
local torso = v:FindFirstChild(“Torso”)
if human and torso and human.Health > 0 then
if (torso.Position - turret.Position).magnitude < aggrodist then
target = torso
end
end
end

if target then
local torso = target
turret.CFrame = CFrame.new(turret.Position, torso.Position)

  local bullet_generation = bullet:Clone()
  bullet_generation.Transparency = 1
  bullet_generation.Velocity = turret.CFrame.LookVector * bullet_speed
  bullet_generation.Parent = game.Workspace
  bullet_generation.Transparency = 0
  
  bullet_generation.Touched:Connect(function(hit)
  	local human = hit.Parent:WaitForChild("Humanoid")
  	if human then
  		human:TakeDamage(bullet_dmg)
  		bullet_generation:Destroy()
  	elseif not human then
  		wait(0.2)
  		bullet_generation:Destroy()
  	end
  end)

end
end

For some reason, the bullet is being fired sideways. Any way I can fix this?
Untitled Game - Roblox Studio (gyazo.com)

1 Like

It will just have to do with the cframe you will need to adjust it . Try to find the front of the bullet you want it facing.

How do I adjust it? I still can’t find out how to.

how about

local pos = CFrame.new(bullet_generation.Position, !!PUT THE TARGETS POSITION HERE!!)
bullet_generation.CFrame = pos

Instead of LookVector, use RightVector or TopVector, and if it starts shooting backwards make bullet_speed negative.

Still shooting sideways for some reason

When I do this it doesnt aim at the target.

Maybe it’s shooting sideways since your bullet is scaled on the X or Y axis and not on the Z Axis.