cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 08 Nov 2015 06:43 PM |
dist = 50 function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local temp = nil local human = nil local temp2 = nil local NAMES = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Torso") human = temp2:findFirstChild("Humanoid") 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
function Hit(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = human.Health-0 end end local torso = script.Parent.Torso torso.Touched:connect(Hit)
while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Animal:MoveTo(target.Position, target)--and this humanoid/zombie else end end
Here is the script, the model itself is two bricks one named "Torso" and the other named "Head" there is a Humanoid called "Animal" the walkspeed is -10 (so it runs away) and the other thing in the model is this script and a weld in the torso connecting it to the head.
So my problem is that the two bricks just sit there and don't move. I know it probably has to do with the fact of no arms or legs, but how can I get the "Animal" to move away from "Humanoids", but while still having health and a walkspeed? |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
z4qqq6
|
  |
| Joined: 05 Jul 2010 |
| Total Posts: 87 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Nov 2015 07:18 PM |
war, unlike you he didn't claim he made it.
To move it away, use the opposite direction -(nearestTorso - torso).unit and call MoveTo and move it in that direction x studs (multiply it by x) |
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 08 Nov 2015 07:22 PM |
| I fixed the problem, I just added arms/legs to the model and made them invisible. I guess it had something to with the Humanoid factor. |
|
|
| Report Abuse |
|
|
z4qqq6
|
  |
| Joined: 05 Jul 2010 |
| Total Posts: 87 |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 08 Nov 2015 07:33 PM |
Aaannnddd it broke again
now the humanoidrootpart runs away (like it's supposed to) but the rest of the rabbit stays behind (not right).
I tired Welding the part with the part0 being the humanoidrootpart, and part1 being the torso, but now it doesn't move at all, what else can I do?
It was working, then i changed the face decal and it stopped working... |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2015 07:34 PM |
"war, unlike you he didn't claim he made it."
OH MY GOSH HE DIDN'T SOURCE ANYBODY THOUGH.
!!!!!!!!
SOMEBODY CALL THE COPYRIGHT POLICE, THIS GUY IS LIKE A MAJOR VIOLATION.
cnt, you really gotta let things go bro. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 08 Nov 2015 07:34 PM |
Ooo
DrHaximus joined Roblox on my birthday :D |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
|
| 08 Nov 2015 09:56 PM |
Mad as in insane or angry? If the former, yes, for about 8 months now.
If the latter, not really, just trying to prove a point. |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 09 Nov 2015 03:59 PM |
Now the humanoidrootpart runs away (like it's supposed to) but the rest of the rabbit stays behind (not right).
I tired Welding the part with the part0 being the humanoidrootpart, and part1 being the torso, but now it doesn't move at all, what else can I do? |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
| |
|