Advertisement
Guest User

Object Aim script for rblx studio!

a guest
Dec 8th, 2019
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. --an roblox lua object aim script!:
  2.  
  3. function findTorso(pos)
  4.     local torso = nil
  5.     local dist = 100000
  6.     local child = workspace:children()
  7.     for i=1, #child do
  8.         if child[i].className == "Model" then
  9.             local h = child[i]:findFirstChild("Humanoid")
  10.             if h ~= nil then
  11.                 local check = child[i]:findFirstChild("Torso")
  12.                 if check ~= nil then
  13.                     if (check.Position - pos).magnitude < dist then
  14.                         torso = check
  15.                         dist = (check.Position - pos).magnitude
  16.                     end
  17.                 end
  18.             end
  19.         end
  20.     end
  21.     return torso
  22. end
  23.  
  24. while true do
  25.     wait()
  26.     for i = 1,5
  27.     do
  28.         local torso = findTorso(script.Parent.Position)
  29.         if torso ~= nil then
  30.             script.Parent.CFrame = CFrame.new(script.Parent.Position, torso.Position)
  31.         end
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement