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: Why doesn't this hurt a Humanoid?

Previous Thread :: Next Thread 
YaYaBinks3 is not online. YaYaBinks3
Joined: 05 Jun 2009
Total Posts: 2631
22 Oct 2011 08:06 AM
    local laser = script.Parent
    
    function onTouched(hit)
    
        local h = hit.Parent:FindFirstChild("Humanoid")
        if (h ~= nil and hit.Name ~= "bang" and hit.Name ~= "bang2") then
    
    h:TakeDamage(10)
    laser:Remove()
      
    
    else
    
    laser:Remove()
    
    end
    end
    script.Parent.Touched:connect(onTouched)

So basically I am shooting this at a Humanoid. Not a player, it's a working Humanoid, know what I mean? Anyway, it isn't damaging, so I'm puzzled. Anyone help please?

> Note: The Humanoid does not have a forcefield
Report Abuse
skipperguy12 is not online. skipperguy12
Joined: 09 Oct 2009
Total Posts: 955
22 Oct 2011 08:09 AM
TakeDamage? Not a function... change to h.Health = 90

Hope it works??
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
22 Oct 2011 08:13 AM
Skipper :TakeDamage() is a method and it works.
Report Abuse
bourlo is not online. bourlo
Joined: 11 Aug 2009
Total Posts: 399
22 Oct 2011 08:13 AM
i dont know maybe it shouldnt be local
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
22 Oct 2011 08:14 AM
local laser = script.Parent

function onTouched(hit)

local h = hit.Parent:FindFirstChild("Humanoid")
if h and hit.Parent.Name == "Bang" and hit.Parent.Name == "Bang2" then

h:TakeDamage(10)
laser:Remove()


else

laser:Remove()

end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
skipperguy12 is not online. skipperguy12
Joined: 09 Oct 2009
Total Posts: 955
22 Oct 2011 08:15 AM
Oh. Sorry, I didn't read about TakeDamage. Sorry! Just read on wiwki, it should work. =\
Report Abuse
skipperguy12 is not online. skipperguy12
Joined: 09 Oct 2009
Total Posts: 955
22 Oct 2011 08:16 AM
Maybe you should replace it with

for i = 100,90,-10 do
h.Health = i
end

=\
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
22 Oct 2011 08:17 AM
That would kill the human when the bullet hits the first time.
Report Abuse
eSvena is not online. eSvena
Joined: 11 Aug 2011
Total Posts: 75
22 Oct 2011 08:34 AM
Yea, this script will be executed 10 time ( 100 - 90 = 10 ) and all the time, the script will do -10 then -10*10 = -100 ^^
Report Abuse
eSvena is not online. eSvena
Joined: 11 Aug 2011
Total Posts: 75
22 Oct 2011 08:36 AM
Or, you can use that :

Humanoid.Health = Humanoid.Health - 10

^^
Report Abuse
NBCKing is not online. NBCKing
Joined: 09 Oct 2011
Total Posts: 133
22 Oct 2011 08:52 AM
Usually, I use output, so I see whats wrong, so I can just post the area thats wrong.
Report Abuse
YaYaBinks3 is not online. YaYaBinks3
Joined: 05 Jun 2009
Total Posts: 2631
22 Oct 2011 08:56 AM
You are all WRONG.

Bikerking, you just added another end and made the 'bang's Bang. So now that won't work.
Output obviously doesn't show anything.
And a bunch of other stuff. Can somebody just actually fix this other than discussing it? T.T
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
22 Oct 2011 08:59 AM
d = 10

h:TakeDamage(d)

Should work.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
22 Oct 2011 09:00 AM
I was going to 'actually fix' it but nvm because if you actually looked into my code it would say 'if h and hit.Parent.Name == "Bang" and hit.Parent.Name == "Bang2" then' And that probably would of worked so ya now im not going to help you because you 1) Yelled at me. 2) You said that I just added 1 more end when I didnt. 3) You`re a noob and get out.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
22 Oct 2011 09:04 AM
Skipper, the difference between TakeDamage() and just subtracting ones health is that the TakeDamage() method wouldn't affect the health of one if they have a spawn shield.

­<'+1 Post. Ujelly?'>
Report Abuse
YaYaBinks3 is not online. YaYaBinks3
Joined: 05 Jun 2009
Total Posts: 2631
31 Oct 2011 07:16 AM
Make me get out. Also, Output didn't like your script.
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