I was making a turrent that shoots bullet but the bullet goes downward
Any help is appreciated
script here
local repstorage = game:GetService(“ReplicatedStorage”)
local bullet = repstorage:WaitForChild(“Bullet”)
local turrent = script.Parent
local firerate = 0.5
local damage = 5
local speedbullet = 150
local agrodistance = 300
while wait(firerate) do
-- find target detect if its real to shoot
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 - turrent.Position).magnitude < agrodistance then
target = torso
end
end
end
if target then
local torso = target
turrent.CFrame = CFrame.new(turrent.Position, torso.Position)
local turrentbullet = bullet:Clone()
turrentbullet.Position = turrent.Position
turrentbullet.Parent = game.Workspace
turrentbullet.Velocity = turrent.CFrame.LookVector * speedbullet
turrentbullet.Touched:Connect(function(objecthit)
local human = objecthit.Parent:FindFirstChild("Humanoid")
if human then
human:TakeDamage(damage)
end
end)
end
end