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
 

Humanoid isn't taking damage on response

Previous Thread :: Next Thread 
denty315 is not online. denty315
Joined: 12 Oct 2008
Total Posts: 16937
18 Oct 2013 08:44 PM
This script is set so that when the value inside the model equals 1, then the players starts taking damage repeatedly until the value changes (don't worry, value is covered, I watched it work.), but for some strange reason, no matter what I try, I cannot get the player to take damage. Output shows nothing, and I can't seem to figure out the issue.

if script.Parent.Energy.Value == 1 then
Player.Character:findFirstChild("Humanoid")
Humanoid.Health = Humanoid.Health -1
wait(0.3)
end

I tried that, and I tried

script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid").Health = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid").Health - 1
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
18 Oct 2013 08:46 PM
script.parent.function:connect () -- arent you supposed to add this??? And why is there no function?
Report Abuse
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
18 Oct 2013 08:47 PM
LOL

Y u no :TakeDamage()????

Assuming Player is defined

if script.Parent.Energy.Value == 1 then
Player.Character:findFirstChild("Humanoid").Health:TakeDamage(1)
wait(0.3)
end

LOOP VERSION
while wait() do
if script.Parent.Energy.Value == 1 then
Player.Character:findFirstChild("Humanoid").Health:TakeDamage(1)
wait(0.3)
else return end
end

And you did the Humanoid thing wrong, you didn't set a variable.
Report Abuse
denty315 is not online. denty315
Joined: 12 Oct 2008
Total Posts: 16937
18 Oct 2013 08:47 PM
Hey, I'm new to this whole process.

I thought I was supposed to put a function, but I didn't know.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
18 Oct 2013 08:47 PM
player = game.Players.LocalPlayer
while true do
if player.Energy.Value == 1 and player.Character then
player.Character.Humanoid:TakeDamage(1)

end
wait(0.2)
end
Report Abuse
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
18 Oct 2013 08:49 PM
Whoops, I forgot to take off the Health part!
Report Abuse
denty315 is not online. denty315
Joined: 12 Oct 2008
Total Posts: 16937
18 Oct 2013 08:51 PM
@qrrr

Even with that adjustment, it shows nothing in output, yet refuses to give the player damage.
Report Abuse
denty315 is not online. denty315
Joined: 12 Oct 2008
Total Posts: 16937
18 Oct 2013 08:58 PM
Fixed it *partially* on my own, used the code source given to me here, then adjusted it, and now it works efficiently.

player = game.Players.LocalPlayer
while true do
if script.Parent.Parent.Energy.Value == 1 and player.Character then
player.Character.Humanoid:TakeDamage(1)
end
wait(0.2)
end

The Value was located in a GUI, so I had to adjust it to search for the value in the GUI rather then the player.
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
18 Oct 2013 08:59 PM
instead of Humanoid.Health = Humanoid.Health - 1 use Humanoid:TakeDamage(1)
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