SHOW:
|
|
- or go back to the newest paste.
1 | --Credits Professeur3 | |
2 | -- NO IDEA WHAT GAME THIS IS FOR | |
3 | local larm = script.Parent:FindFirstChild("HumanoidRootPart") | |
4 | local rarm = script.Parent:FindFirstChild("HumanoidRootPart") | |
5 | ||
6 | function findNearestTorso(pos) | |
7 | local list = game.Workspace:children() | |
8 | local torso = nil | |
9 | local dist = 10000 | |
10 | local temp = nil | |
11 | local human = nil | |
12 | local temp2 = nil | |
13 | for x = 1, #list do | |
14 | temp2 = list[x] | |
15 | if (temp2.className == "Model") and (temp2 ~= script.Parent) then | |
16 | temp = temp2:findFirstChild("HumanoidRootPart") | |
17 | human = temp2:findFirstChild("Humanoid") | |
18 | if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then | |
19 | if (temp.Position - pos).magnitude < dist then | |
20 | torso = temp | |
21 | dist = (temp.Position - pos).magnitude | |
22 | end | |
23 | end | |
24 | end | |
25 | end | |
26 | return torso | |
27 | end | |
28 | ||
29 | ||
30 | ||
31 | ||
32 | while true do | |
33 | wait(math.random(1,5)) | |
34 | local target = findNearestTorso(script.Parent.HumanoidRootPart.Position) | |
35 | if target ~= nil then | |
36 | script.Parent.Humanoid:MoveTo(target.Position, target) | |
37 | end | |
38 | ||
39 | end |