generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How to stop zombies from attacking each other?

Previous Thread :: Next Thread 
ToonU is not online. 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 is not online. 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 is not online. 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 is not online. 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
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
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 is not online. ToonU
Joined: 15 Aug 2011
Total Posts: 6303
14 Dec 2012 08:38 PM
Thanks, it worked!! :)


trollfaic
Report Abuse
SuperSneakyTony is not online. SuperSneakyTony
Joined: 10 Jul 2011
Total Posts: 4428
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image