torso = script.Parent.Torso maxrange = 70 minrange = 20 target = nil tor = nil function findNearestTarget() plrs = game.Players:GetChildren() for i, plr in ipairs(plrs) do if plr.Character ~= nil then if plr.Character:findFirstChild("Humanoid") and plr.Character.Humanoid.Health>0 then tor = plr.Character.Torso if target == nil then if ((torso.Position - tor.Position).magnitude <= maxrange) then if ((torso.Position - tor.Position).magnitude >= minrange) then target = plr.Character else target = nil script.Parent.Zombie:MoveTo(script.Parent.Head.Position, script.Parent.Head) end else target = nil script.Parent.Zombie:MoveTo(script.Parent.Head.Position, script.Parent.Head) end end end end end end head = script.Parent:WaitForChild("Head") function Shoot () local ball = Instance.new("Part") ball.Name = "Ball" ball.BrickColor = BrickColor.new("White") ball.Shape = "Ball" ball.Size = Vector3.new(1,1,1) ball.CanCollide = false ball.CFrame = head.CFrame ball.Velocity = tor.CFrame*20 ball.Parent = game.Workspace end while true do wait(.1) findNearestTarget() if target ~= nil then wait(2) Shoot() print ("Shooted") end end
So, what this is supposed to do, is that when this humanoid has a target he shoots on its direction. But he shoots downward and not on the targets direction. Help?
the FrontSurface of the part that the ball
ball comes out off has to Face ere he is Facing...