FurkingBoi

Ro Slayer

Mar 20th, 2020
3,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. local players = game:service'Players';
  2. local tweenService = game:service'TweenService';
  3. local runService = game:service'RunService';
  4. local replicatedStorage = game:service'ReplicatedStorage';
  5. local virtualUser = game:service'VirtualUser';
  6. local camera = workspace.CurrentCamera
  7. local player = players.LocalPlayer;
  8. local playerGui = player.PlayerGui;
  9. local vec3New = Vector3.new;
  10. local vec2New = Vector2.new;
  11. local cframeNew = CFrame.new;
  12. local tweenInfoNew = TweenInfo.new;
  13. local constVec = vec3New(0, 5, 0);
  14. local constVec2 = vec2New(0, 0);
  15. local mouse = player:GetMouse();
  16.  
  17. local equipRemote = replicatedStorage.Remotes.E;
  18.  
  19. local function punch()
  20. virtualUser:Button1Down(constVec2, camera.CFrame);
  21. end
  22. local function equip()
  23. if player.Character:WaitForChild('Humanoid').Equip.Value then return end;
  24. local headBillGui = player.Character.Head:FindFirstChild("HeadBillGui");
  25. if headBillGui then
  26. headBillGui:Destroy();
  27. end
  28. equipRemote:FireServer(true);
  29. wait(1.1);
  30. end
  31.  
  32. local function getNearestMob()
  33. local nearestM, nearest = 9e9;
  34. local playerHum = player.Character.HumanoidRootPart;
  35. local workspaceChild = workspace:GetChildren();
  36. for i = 1, #workspaceChild do
  37. local v = workspaceChild[i];
  38. local mobHum = v:FindFirstChild("Humanoid");
  39. if v:IsA'Model' and v.Name:find'Demon' and not players:FindFirstChild(v.Name) and mobHum and mobHum.Health > 0 then
  40. local mobRootPart = v.HumanoidRootPart;
  41. local magnitude = (playerHum.Position - mobRootPart.Position).Magnitude;
  42. if magnitude < nearestM then
  43. nearestM = magnitude;
  44. nearest = mobRootPart;
  45. end
  46. end
  47. end
  48. return nearest, nearestM, playerHum
  49. end
  50.  
  51. runService.Stepped:Connect(function()
  52. local humanoid = player.Character:WaitForChild("Humanoid");
  53. humanoid:ChangeState(11);
  54. equip();
  55. punch();
  56. end)
  57.  
  58. while true do
  59. local nearest, distance, playerHum = getNearestMob();
  60. if nearest then
  61. local mob = nearest.Parent;
  62. repeat
  63. local playerCFrame = playerHum.CFrame;
  64. local mobPos = nearest.Position;
  65. local tpCFrame = cframeNew((mobPos - constVec), mobPos)
  66. local tweenBase = tweenService:Create(playerHum, tweenInfoNew(distance / 200), {CFrame = tpCFrame});
  67. tweenBase:Play();
  68. tweenBase.Completed:Wait();
  69. until mob.Humanoid.Health <= 0;
  70. end
  71. wait(3.5);
  72. end;
Add Comment
Please, Sign In to add comment