Hasli4

RBLX. BossSeek

Jan 9th, 2026
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local Pirate = script.Parent.PirateType
  2.  
  3. function findNearestTorso(pos)
  4.     local list = game.Workspace:children()
  5.     local torso = nil
  6.     local dist = 50 --This Line Right Here
  7.     local temp = nil
  8.     local human = nil
  9.     local temp2 = nil
  10.     for x = 1, #list do
  11.         temp2 = list[x]
  12.         if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  13.             temp = temp2:findFirstChild("Head")
  14.             human = temp2:findFirstChild("Humanoid")
  15.             local Friend = temp2:findFirstChild("Friend")
  16.             if (temp ~= nil) and (human ~= nil) and (Friend == nil) or (temp ~= nil) and (human ~= nil) and (human.Health > 0) and (Friend.Value ~= script.Parent.Friend.Value) then
  17.                 if (temp.Position - pos).magnitude < dist then
  18.                     torso = temp
  19.                     dist = (temp.Position - pos).magnitude
  20.                 end
  21.             end
  22.         end
  23.     end
  24.     return torso
  25. end
  26. while true do
  27.     wait(0.1)
  28.     local target = findNearestTorso(script.Parent.LeftHand.Position)
  29.     if target ~= nil then
  30.         Pirate.WalkSpeed = script.Parent.WalkSpeed.Value
  31.         script.Parent.PirateType:MoveTo(target.Position, target)
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment