ToonU
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 6303 |
|
|
| 14 Dec 2012 08:23 PM |
My problem is that when zombies spawn near another zombie, they ignore the player and go for the other zombie.
Here's my current script: ----------------------------
local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm")
if ~= 4 then function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 30 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("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 end
function Hit(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = human.Health -10 end end
larm.Touched:connect(Hit) rarm.Touched:connect(Hit)
while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position, target) end end ---
What it does: Finds nearest Humanoid (In this case, the zombie.), Kills.
How can I get it to only attack players? Thanks.
trollfaic |
|
|
| Report Abuse |
|
|
peaspod
|
  |
| Joined: 29 Sep 2010 |
| Total Posts: 2809 |
|
|
| 14 Dec 2012 08:25 PM |
| The humanoid in the zombies should not be called humanoid. Try changing it to zombie. |
|
|
| Report Abuse |
|
|
ToonU
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 6303 |
|
|
| 14 Dec 2012 08:26 PM |
@Peas
When I do that, it does not lose health.
trollfaic |
|
|
| Report Abuse |
|
|
peaspod
|
  |
| Joined: 29 Sep 2010 |
| Total Posts: 2809 |
|
|
| 14 Dec 2012 08:28 PM |
| Then in the weapons you need to edit it so that they take away health from "zombie" and not humanoid |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2012 08:36 PM |
There wouldn't be problem if you hadn't of used a free model.
Make sure that there is a ClassName of 'Humanoid' in your zombie and replace the name of it to 'Zombie'. Then in all of your weapons replace the 'Humanoids' with 'Zombie'.
~LUV, LuaLearners Teacher(+2)~ |
|
|
| Report Abuse |
|
|
ToonU
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 6303 |
|
|
| 14 Dec 2012 08:38 PM |
Thanks, it worked!! :)
trollfaic |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2012 08:38 PM |
| You should make a new game called "Zombie Brawl" where people bet a certain amount of money on either Zombie1 or Zombie2 and whichever zombie they betted on, and wins. Their money doubles, they then can buy gears for their zombie to use. |
|
|
| Report Abuse |
|
|
ToonU
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 6303 |
|
|
| 14 Dec 2012 08:43 PM |
@Super how about you? :3
I'm making a BO Nuketown ZOMBIES game for some tix.. I'm kinda poor lol
trollfaic |
|
|
| Report Abuse |
|
|