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: "Kill on touch" script help

Previous Thread :: Next Thread 
Coachsam is not online. Coachsam
Joined: 16 May 2008
Total Posts: 4140
27 Sep 2013 08:11 PM
Let me give you a quick briefing:

So I am about to update my game by adding in a truck that kills zombies when you run them over. There are certain zombies in my game however that I don't want to die when they get hit by the truck. I want to keep the humanoid names the same for both zombies so that the guns in my game will still damage both types. I've tried a lot but nothing seems to be working (I'm new to this).

Here is the original script:

===================

function onTouch(part)
local zombie = part.Parent:findFirstChild("Zombie")
if (zombie == nil) then return end
zombie.Health = 0
end
script.Parent.Touched:connect(onTouch)

===================

I tried adding in string value named "StringValue" but that didn't work for me (I'm guessing its because I don't know how to use string value properly) Here is what I got. This still kills both zombies and just pretty much ignores the 3rd line.

===================

function onTouch(part)
local Zombie = part.Parent:findFirstChild("Zombie")
if (part.Parent:findFirstChild("StringValue") == true) then return end
if (Zombie == nil) then return end
Zombie.Health = 0
end
script.Parent.Touched:connect(onTouch)

===================

Then I was like 'screw this, I'm going to see if I can make it work by name.'

===================

function onTouch(part)
local Zombie = part.Parent:findFirstChild("Zombie")
if (part.Parent == BehemothZombie == true) then return end
if (Zombie == nil) then return end
Zombie.Health = 0
end
script.Parent.Touched:connect(onTouch)

===================

Needless to say, it didn't work.

If you can help me out to get the desired results that I'm looking for, I will be glad to give you 2K tickets.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Sep 2013 08:51 PM
Your first attempt should have worked if you had set it up correctly. How was it set up?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Sep 2013 08:53 PM
Oh, I see what you're trying to do. The third line in your first attempt jettisons the function when an object named "Zombie" does not exist in the touched part's parent. Otherwise, you assume it's a humanoid and kill it, so the program is doing exactly what you told it to. What are the differences between the zombie types? (The objects, not the abilities)
Report Abuse
tummey2 is not online. tummey2
Joined: 04 Feb 2009
Total Posts: 1802
27 Sep 2013 08:53 PM
function onTouch(part)
local zombie = part.Parent:findFirstChild("Zombie")
if (zombie == nil) then return end
zombie.Health = 0
end
script.Parent.Touched:connect(onTouch)

Is "zombie" the name of the Humanoid?
Report Abuse
Coachsam is not online. Coachsam
Joined: 16 May 2008
Total Posts: 4140
27 Sep 2013 08:58 PM
I placed the script inside the brick I wanted to kill the zombies.

I then added in a string value into the zombie I wanted to survive (the default name was Value, but I changed it to StringValue)

In the script I had it so that it would look for the child only, but I noticed that a stringvalue has a property of 'value' that can be changed. Does that have anything to do with it?
Report Abuse
Coachsam is not online. Coachsam
Joined: 16 May 2008
Total Posts: 4140
27 Sep 2013 08:58 PM
And yes, the humanoid is named "Zombie."
Report Abuse
Coachsam is not online. Coachsam
Joined: 16 May 2008
Total Posts: 4140
27 Sep 2013 09:00 PM
The difference between the zombie types:

The one that dies DOESN'T have string value.

The one that doesn't die (or shouldn't die) DOES have a stringvalue object.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Sep 2013 09:01 PM
script.Parent.Touched:connect(function(part)
    local zombie = part.Parent:findFirstChild("Zombie")
    if zombie and not part.Parent:findFirstChild'StringValue' then--Remove the "not" if you want it to kill zombies WITH the StringValue.
        zombie.Health = 0
    end
end)
Report Abuse
Coachsam is not online. Coachsam
Joined: 16 May 2008
Total Posts: 4140
27 Sep 2013 09:06 PM
@Monkey

Your script works! Thank you! I notice you don't have BC, but is there any other way I can repay you?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
27 Sep 2013 09:07 PM
Promote my game? :D
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