I have bullet system but it is going into the ground
script
function FindTarget()
local maxDistance = script.Parent.Parent.DetectionDistance.Value
local target = nil
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if (v.Head.Position-script.Parent.Position).magnitude < maxDistance then
target = v.Head
end
end
end
return target
end
while wait(script.Parent.Parent.ShootCooldown.Value) do
local target = FindTarget()
if target then
local cln = Instance.new("Part")
cln.Size = Vector3.new(1,1,2)
cln.CanCollide = false
cln.CFrame = script.Parent.CFrame
cln.Transparency = .5
cln.BrickColor = BrickColor.new("New Yeller")
local velo = Instance.new("LinearVelocity")
local att = Instance.new("Attachment")
velo.Attachment0 = att
-- velo.Attachment1 = target:WaitForChild("LockOnAtt")
-- velo.MaxForce = Vector3.new(script.Parent.Parent.ShootForce.Value,script.Parent.Parent.ShootForce.Value,script.Parent.Parent.ShootForce.Value)
velo.VectorVelocity = Vector3.new(0,0,500)
-- velo.Velocity = target.Position
-- velo.P = 99999999999999999
-- velo.VectorVelocity = Vector3.new(velo.VectorVelocity.Z/10,velo.VectorVelocity.Y,velo.VectorVelocity.Z)
velo.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
velo.Parent = cln
att.Parent = cln
cln.Parent = workspace
end
end
i replaced the line with that code now its doing this
edit:
it turns out it was because i needed to make the maxforce a high number
new code
function FindTarget()
local maxDistance = script.Parent.Parent.DetectionDistance.Value
local target = nil
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if (v.Head.Position-script.Parent.Position).magnitude < maxDistance then
target = v.Head
end
end
end
return target
end
while wait(script.Parent.Parent.ShootCooldown.Value) do
local target = FindTarget()
if target then
local cln = Instance.new("Part")
cln.Massless = true
cln.Size = Vector3.new(1,1,2)
cln.CanCollide = false
local Y = cln.Position.Y
cln.CFrame = script.Parent.CFrame
cln.Transparency = .5
cln.BrickColor = BrickColor.new("New Yeller")
local velo = Instance.new("LinearVelocity")
local att = Instance.new("Attachment")
velo.Attachment0 = att
velo.MaxForce = 99999999999999999999
-- velo.Attachment1 = target:WaitForChild("LockOnAtt")
-- velo.MaxForce = Vector3.new(script.Parent.Parent.ShootForce.Value,script.Parent.Parent.ShootForce.Value,script.Parent.Parent.ShootForce.Value)
velo.VectorVelocity = Vector3.new(0,0,500)
-- velo.VectorVelocity = (target.Position + script.Parent.Position).Unit * 500
-- velo.Velocity = target.Position
-- velo.P = 99999999999999999
-- velo.VectorVelocity = Vector3.new(velo.VectorVelocity.Z/10,velo.VectorVelocity.Y,velo.VectorVelocity.Z)
velo.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
velo.Parent = cln
att.Parent = cln
cln.Parent = workspace
end
end