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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|