Advertisement
Glexteon

Untitled

Oct 16th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. --[[
  2. Hi.
  3. ]]--
  4.  
  5. function FindNearest(position)
  6. local lowest = math.huge -- infinity
  7. local NearestPlayer = nil
  8. for i,v in pairs(game.Players:GetPlayers())do
  9. if v.Name~=game.Players.LocalPlayer.Name then
  10. if v and v.Character then
  11. local distance = v:DistanceFromCharacter(position)
  12. if distance < lowest then
  13. lowest = distance
  14. NearestPlayer = v
  15. end
  16. end
  17. end
  18. end
  19. return NearestPlayer
  20. end
  21. while(true)do
  22. wait()
  23. target=FindNearest(game.Players.LocalPlayer.Character:WaitForChild("Head").Position);
  24. target=target.Name;
  25. print(target)
  26. if game.Workspace[target]:FindFirstChild("Humanoid") then
  27. if game.Workspace[target].Humanoid.Health>1 then
  28. remote=game.Workspace[game.Players.LocalPlayer.Name]:WaitForChild("Gravity Inducer").WeaponEvent
  29. args={
  30. "Fire", game.Workspace[target]:WaitForChild("Head").Position
  31. }
  32. remote:FireServer(unpack(args))
  33. else
  34. target=FindNearest(game.Players.LocalPlayer.Character.Head.Position);
  35. target=target.Name;
  36. end
  37. end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement