Advertisement
Er1x_Official

Nextbot Script

Jul 25th, 2022
4,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local ServerStorage = game:GetService("ServerStorage")
  2. local SimplePath = require(ServerStorage:WaitForChild("SimplePath")) -- in server storage
  3.  
  4. local Goal = nil -- goal / target
  5. local Bot = script.Parent -- the bot
  6. local Path = SimplePath.new(Bot) -- create a path
  7.  
  8. function findnearestPlayer(Origin:Vector3,MaxDistance:number)
  9.     local Players = game:GetService("Players")
  10.     local NearestPlayer,NearestDistance
  11.    
  12.     for i,player in pairs(Players:GetPlayers()) do
  13.         local character = player.Character
  14.         local distance = player:DistanceFromCharacter(Origin)
  15.        
  16.         if not character or distance > MaxDistance or (NearestDistance and distance >= NearestDistance) then
  17.             continue
  18.         end
  19.        
  20.         NearestDistance = distance
  21.         NearestPlayer = player
  22.     end
  23.    
  24.     return NearestPlayer
  25. end
  26.  
  27. while true do
  28.     Goal = findnearestPlayer(Bot.PrimaryPart.Position,5000)
  29.     if Goal then
  30.         Path:Run(Goal.Character.PrimaryPart.Position)
  31.         if (Goal.Character.PrimaryPart.Position - Bot.PrimaryPart.Position).Magnitude < 4 then
  32.             local Humanoid = Goal.Character:FindFirstChildOfClass("Humanoid")
  33.             if Humanoid then
  34.                 Humanoid:TakeDamage(30) -- damage
  35.             end
  36.         end
  37.     end
  38.    
  39.     task.wait()
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement