The code below is from my friend, who asked me to help him, but i can’t exactly see what is causing the error, from what he said:
“I have a code that should make projectiles go towards the player, however, when the code does spawn a ball, the projectile simply falls down
there are no errors, and im using a piece of code from the game in which it works”
function smallbullet()
if phrp and phrp.Parent.Humanoid.Health ~= 0 then
for i = 1, math.random(3,8) do
for _,shot in pairs(shots) do
local bull = Instance.new("Part", workspace)
bull.Shape = Enum.PartType.Ball
bull.Material = Enum.Material.Neon
bull.Size = Vector3.new(5,5,5)
bull.CanCollide = false
bull.Position = shot.Position
bull.CFrame = CFrame.lookAt(bull.Position, phrp.Position)
local atcmnt = Instance.new("Attachment", bull)
local vel = Instance.new("LinearVelocity", bull)
vel.Attachment0 = atcmnt
vel.ForceLimitMode = Enum.ForceLimitMode.PerAxis
vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
vel.VectorVelocity = bull.CFrame.LookVector*10
wait(.2)
end
wait(.5)
end
end
end
phrp is the torso of the player and shots are the two parts that shoot the projectiles