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 » Scripters
Home Search
 

My Zombie Attacks Other Zombies?

Previous Thread :: Next Thread 
Zanewuzhere is not online. Zanewuzhere
Joined: 26 Jun 2014
Total Posts: 146
31 Aug 2015 09:14 AM
Hey! I'm working on a game, and I built a zombie and scripted it, but it attacks other zombies. You can fix it by taking out the humanoid, or renaming the Humanoid, but if I do that, it makes my zombie invincible. I've tried putting in a health script, but that doesn't work. I know in games like Apocalypse Rising, the zombies won't attack one another and still have health. Any help is appreciated!
Report Abuse
AdamHighDefinition is not online. AdamHighDefinition
Joined: 09 Aug 2015
Total Posts: 628
31 Aug 2015 09:31 AM
Post your script.
Report Abuse
DermonDarble is not online. DermonDarble
Joined: 04 Jun 2015
Total Posts: 2576
31 Aug 2015 09:33 AM
When finding the thing to attack, check if it's a player or not.
Report Abuse
ApocSurrvivalist is not online. ApocSurrvivalist
Joined: 22 Apr 2013
Total Posts: 5840
31 Aug 2015 09:34 AM
Name all the zombies the same and do

and (temp2.Name ~= "YOURZOMBIESNAMES")
Report Abuse
Zanewuzhere is not online. Zanewuzhere
Joined: 26 Jun 2014
Total Posts: 146
31 Aug 2015 09:40 AM
Here's my current attack script:

function waitForChild(parent, childName)
while true do
local child = parent:findFirstChild(childName)
if child then
return child
end
parent.ChildAdded:wait()
end
end

local w = waitForChild(script.Parent, "Zombie")
w.MaxHealth = 60
w.Health = 60
w.WalkSpeed = 20
set = 1.5
local head = script.Parent:FindFirstChild("FakeHead")

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 50
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, dist
end

db = false

function Hit(hit)
if db then return end
db = true
if hit ~= nil and hit.Size.y >= 10 then
ran = math.random(1, 2)
if ran == 1 then
cf2 = script.Parent.Torso.CFrame*CFrame.new(-20, 0, 5)
elseif ran == 2 then
cf2 = script.Parent.Torso.CFrame*CFrame.new(20, 0, 5)
end

local part2 = Instance.new("Part")
part2.Parent = script.Parent
part2.Transparency = 1
part2.Size = Vector3.new(1, 1, 1)
part2.Anchored = true
part2.Locked = true
part2.CanCollide = false
part2.CFrame = cf2
start2 = part2.Position
script.Parent.Zombie:MoveTo(start2, part2)
wait(2)
part2:remove()
elseif hit ~= nil and hit.Size.y <= 10 and hit.Parent:findFirstChild("Humanoid") == nil or hit ~= nil and hit.Name == "Baricade" and hit.Parent:findFirstChild("Humanoid") == nil then
script.Parent.Zombie.Jump = true
end
trh=script.Parent.Torso:findFirstChild("Right Shoulder")
tlh=script.Parent.Torso:findFirstChild("Left Shoulder")
if trh ~= nil and tlh~=nil then
trh.CurrentAngle = 0.8
tlh.CurrentAngle = -0.7
end
db = false
end

con = head.Touched:connect(Hit)

function died()
con:disconnect()
wait(5)
script.Parent:remove()
end

script.Parent.Zombie.Died:connect(died)

while true do
wait(0.3)
local target, dist = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Zombie:MoveTo(target.Position, target)
if dist<5 then
target.Parent.Humanoid.Health = target.Parent.Humanoid.Health - 4
trh=script.Parent.Torso:findFirstChild("Right Shoulder")
tlh=script.Parent.Torso:findFirstChild("Left Shoulder")
if trh ~= nil and tlh~=nil then
trh.CurrentAngle = set
tlh.CurrentAngle = -set
if set == 0.1 then set = 0.1 else set = 0.1 end
end
wait(0.2)
end
end
end

Report Abuse
ApocSurrvivalist is not online. ApocSurrvivalist
Joined: 22 Apr 2013
Total Posts: 5840
31 Aug 2015 09:42 AM
function waitForChild(parent, childName)
while true do
local child = parent:findFirstChild(childName)
if child then
return child
end
parent.ChildAdded:wait()
end
end

local w = waitForChild(script.Parent, "Zombie")
w.MaxHealth = 60
w.Health = 60
w.WalkSpeed = 20
set = 1.5
local head = script.Parent:FindFirstChild("FakeHead")

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 50
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) and (temp2.Name ~ = "ZOMBIE") 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, dist
end

db = false

function Hit(hit)
if db then return end
db = true
if hit ~= nil and hit.Size.y >= 10 then
ran = math.random(1, 2)
if ran == 1 then
cf2 = script.Parent.Torso.CFrame*CFrame.new(-20, 0, 5)
elseif ran == 2 then
cf2 = script.Parent.Torso.CFrame*CFrame.new(20, 0, 5)
end

local part2 = Instance.new("Part")
part2.Parent = script.Parent
part2.Transparency = 1
part2.Size = Vector3.new(1, 1, 1)
part2.Anchored = true
part2.Locked = true
part2.CanCollide = false
part2.CFrame = cf2
start2 = part2.Position
script.Parent.Zombie:MoveTo(start2, part2)
wait(2)
part2:remove()
elseif hit ~= nil and hit.Size.y <= 10 and hit.Parent:findFirstChild("Humanoid") == nil or hit ~= nil and hit.Name == "Baricade" and hit.Parent:findFirstChild("Humanoid") == nil then
script.Parent.Zombie.Jump = true
end
trh=script.Parent.Torso:findFirstChild("Right Shoulder")
tlh=script.Parent.Torso:findFirstChild("Left Shoulder")
if trh ~= nil and tlh~=nil then
trh.CurrentAngle = 0.8
tlh.CurrentAngle = -0.7
end
db = false
end

con = head.Touched:connect(Hit)

function died()
con:disconnect()
wait(5)
script.Parent:remove()
end

script.Parent.Zombie.Died:connect(died)

while true do
wait(0.3)
local target, dist = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Zombie:MoveTo(target.Position, target)
if dist<5 then
target.Parent.Humanoid.Health = target.Parent.Humanoid.Health - 4
trh=script.Parent.Torso:findFirstChild("Right Shoulder")
tlh=script.Parent.Torso:findFirstChild("Left Shoulder")
if trh ~= nil and tlh~=nil then
trh.CurrentAngle = set
tlh.CurrentAngle = -set
if set == 0.1 then set = 0.1 else set = 0.1 end
end
wait(0.2)
end
end
end
Report Abuse
Zanewuzhere is not online. Zanewuzhere
Joined: 26 Jun 2014
Total Posts: 146
31 Aug 2015 09:46 AM
Thank you so so so much, now I can get a move on with the game. Have a nice day!
Report Abuse
ApocSurrvivalist is not online. ApocSurrvivalist
Joined: 22 Apr 2013
Total Posts: 5840
31 Aug 2015 09:46 AM
Likewise
Im also working on NPC's
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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