|
| 25 Sep 2014 06:39 PM |
I need help fixing this script: Problem: Doesn't follow "Test"
local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTest(pos) local list = game.Workspace:children() local torso = nil local dist = 25 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Test") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end
while true do wait(0.1) local target = findNearestTest(script.Parent.Test.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position, target) end end
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 25 Sep 2014 06:47 PM |
local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTest(script.Parent.Test.Position) local list = game.Workspace:children() local torso = 0.1 local dist = 25 local temp = nil local human = 20 local temp2 = nil for x = 1, (list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Test") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end)
while true do wait(0.1) local target = findNearestTest(script.Parent.Test.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position; target) end end |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2014 06:47 PM |
| looks like something i've seen before |
|
|
| Report Abuse |
|
|
| |
|
| |
|