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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Why does my zombie remove script not work?

Previous Thread :: Next Thread 
Ihardyhat is not online. Ihardyhat
Joined: 06 Nov 2012
Total Posts: 169
05 Feb 2014 04:32 PM
Damage = script.Parent.Parent.Damage.Value


function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health - Damage
end
end



script.Parent.Touched:connect(onTouched)

if script.Parent.Humanoid.Health<1 then
script.Parent:remove()

end


This is supost to make the script that causes the zombie to do damage, to get removed when the zombie gets killed, Why wont it work? Please help!
Report Abuse
leperdy is not online. leperdy
Joined: 07 Dec 2008
Total Posts: 1406
05 Feb 2014 04:35 PM
in a different script use the Died() listening event to trigger this. Or move your if statement within the function.
Report Abuse
Ihardyhat is not online. Ihardyhat
Joined: 06 Nov 2012
Total Posts: 169
05 Feb 2014 04:35 PM
And,
If I do this:


Damage = script.Parent.Parent.Damage.Value


function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health - Damage
if script.Parent.Humanoid.Health<1 then
script.Parent:remove()

end


end
end



script.Parent.Touched:connect(onTouched)

It will get removed on touch but not when killed, how do I have to do to change that?
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