TheUnknownDiscord

follow

Sep 17th, 2021 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local part1 = Instance.new("Part", game.Workspace)
  2. part1.Size = Vector3.new(1.487, 0.985, 2.72)
  3. local bg = Instance.new("BodyGyro",part1)
  4. bg.D = 100
  5. bg.P = 100000
  6. bg.MaxTorque = Vector3.new(1000000,1000000,1000000)
  7. local velocitylol = Instance.new("BodyVelocity", part1)
  8. coroutine.wrap(function()
  9. while true do
  10. task.wait()
  11. velocitylol.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  12. velocitylol.Velocity = part1.CFrame.LookVector * -32
  13. end
  14. end)()
  15. function move(target)
  16. local dir = (part1.Position - target.Position).unit
  17. local spawnPos = part1.Position
  18. local pos = spawnPos + (dir * 1)
  19. bg.cframe = CFrame.new(pos, pos + dir)
  20. end
  21.  
  22. function findNearestTorso(pos)
  23. local list = game.Workspace:GetChildren()
  24. local torso = nil
  25. local dist = 1000
  26. local temp = nil
  27. local human = nil
  28. local temp2 = nil
  29. for x = 1, #list do
  30. temp2 = list[x]
  31. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  32. temp = temp2:findFirstChild("Head")
  33. human = temp2:findFirstChild("Humanoid")
  34. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  35. if (temp.Position - pos).magnitude < dist then
  36. torso = temp
  37. dist = (temp.Position - pos).magnitude
  38. end
  39. end
  40. end
  41. end
  42. return torso
  43. end
  44. while true do
  45. local torso = findNearestTorso(part1.Position)
  46. if torso~=nil then
  47. move(torso)
  48. end
  49. task.wait()
  50. end
  51.  
Add Comment
Please, Sign In to add comment