stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
|
| 05 Mar 2012 01:17 PM |
For some reason this script isn't picking up the humanoid it's looking for. Any thoughts?:
ball = script.Parent damage = 5 Armour = nil Humanoid2 = ""
function onTouched(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if hit.Parent:FindFirstChild("Infected") == nil then if humanoid ~= nil then Humanoid2 = hit.Parent.Name connection:disconnect() if hit.Parent:FindFirstChild("Chest") ~= nil and hit.Parent:FindFirstChild("Chest").ArmourHP.Value > 0 then Armour = hit.Parent:FindFirstChild("Chest") Armour.ArmourHP.Value = Armour.ArmourHP.Value - damage end else game.Workspace:FindFirstChild(Humanoid2).Humanoid:TakeDamage(damage) end end end
connection = ball.Touched:connect(onTouched)
wait(3) ball:remove()
Output:
19:17:33 - Workspace.Bullet.Paintball:19: attempt to index a nil value 19:17:33 - Script "Workspace.Bullet.Paintball", Line 19 19:17:33 - stack end 19:17:33 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Mar 2012 01:48 PM |
| Change "Chest" to "Torso". |
|
|
| Report Abuse |
|
|
Torcus
|
  |
| Joined: 22 Feb 2012 |
| Total Posts: 885 |
|
|
| 05 Mar 2012 01:49 PM |
| ...Your seriously using 'Chest'? If you want it to be chest, change torso to chest. Problem solved! |
|
|
| Report Abuse |
|
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
|
| 05 Mar 2012 01:50 PM |
| "Chest" is the model of a morph that contains the ArmourHP IntValue. |
|
|
| Report Abuse |
|
|
| |
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
|
| 05 Mar 2012 01:53 PM |
| "game.Workspace:FindFirstChild(Humanoid2).Humanoid:TakeDamage(damage)" |
|
|
| Report Abuse |
|
|
Torcus
|
  |
| Joined: 22 Feb 2012 |
| Total Posts: 885 |
|
|
| 05 Mar 2012 01:58 PM |
@Stroudie,
Welcome to my world. I'm taking a test just to get Scripter Tier-1 in Scripting Helpers Group. |
|
|
| Report Abuse |
|
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
| |
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
| |
|
|
| 05 Mar 2012 02:07 PM |
Try:
ball = script.Parent damage = 5 Armour = nil Humanoid2 = ""
function onTouched(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then if not hit.Parent:FindFirstChild("Infected") then Humanoid2 = hit.Parent.Name connection:disconnect() if hit.Parent:FindFirstChild("Chest") ~= nil and hit.Parent:FindFirstChild("Chest").ArmourHP.Value > 0 then Armour = hit.Parent:FindFirstChild("Chest") Armour.ArmourHP.Value = Armour.ArmourHP.Value - damage end else game.Workspace:FindFirstChild(Humanoid2).Humanoid:TakeDamage(damage) end end end connection = ball.Touched:connect(onTouched) wait(3) ball:remove()
???
† KMXD † |
|
|
| Report Abuse |
|
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
| |
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 06 Mar 2012 12:49 PM |
Humanoid2 = ""
game.Workspace:FindFirstChild(Humanoid2)
So, it has no name..?
Also..
if hit.Parent:FindFirstChild("Chest") ~= nil and hit.Parent:FindFirstChild("Chest").ArmourHP.Value > 0 then Armour = hit.Parent:FindFirstChild("Chest") Armour.ArmourHP.Value = Armour.ArmourHP.Value - damage end else
I think that you meant to put that end after the else part, so that the else works with that if statement? |
|
|
| Report Abuse |
|
|
stroudie
|
  |
| Joined: 28 Nov 2008 |
| Total Posts: 2556 |
|
|
| 06 Mar 2012 03:52 PM |
| Nevermind now. I re-scripted it from scratch which fixed it. |
|
|
| Report Abuse |
|
|