local bullet = game:GetService(“ReplicatedStorage”).Bullet2
local turret = script.Parentlocal aggrodist = 250
local bullet_dmg = 5
local bullet_mag = 300
local reload_time = 0.1
local bullet_speed = 500while 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
endif 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)